- For time consuming actions:
click - some location
waitForPageToLoad
pause
- For page waits for ajax response:
click - ajax button
pause
... next action ...
- Use selenium locator for target:
id=...
css=...
Showing posts with label Testing. Show all posts
Showing posts with label Testing. Show all posts
Monday, November 12, 2012
Thursday, November 8, 2012
Selenium IDE - select element by CSS
select element by css:
<tr>
<td>verifyElementPresent</td>
<td>css=span#direct-debit-scheme-menu-title</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
<td>css=span#direct-debit-scheme-menu-title</td>
<td></td>
</tr>
Friday, October 12, 2012
Run multiple Jenkins Rails test simultaneously
Under the continuous integration platform Jenkins, there can be multiple build projects that may run at the same time. For example, unit tests, functional tests and integration tests.
By default, all projects may have database.yml configurations that points to the same test database. This may lead to failure like this:
...
To allow simultaneously tests, database yml should be modified to use different database:
/var/lib/jenkins/jobs/[Project Name]/workspace/config/database.yml
* Set the max number jobs to be run concurrently on Jenkins' settings.
By default, all projects may have database.yml configurations that points to the same test database. This may lead to failure like this:
...
DETAIL: There are 1 other session(s) using the database. : DROP DATABASE IF EXISTS "test_db"> test_db already exists
...To allow simultaneously tests, database yml should be modified to use different database:
/var/lib/jenkins/jobs/[Project Name]/workspace/config/database.yml
* Set the max number jobs to be run concurrently on Jenkins' settings.
Thursday, October 11, 2012
Selenium IDE Flow Control
https://addons.mozilla.org/en-us/firefox/addon/flow-control/
Example:
<tr>
<td>storeTextPresent</td>
<td>Continue</td>
<td>tp</td>
</tr>
<tr>
<td>gotoIf</td>
<td>!${tp}</td>
<td>Common</td>
</tr>
...
<tr>
<td>label</td>
<td>Common</td>
<td></td>
</tr>
...
Example:
<tr>
<td>storeTextPresent</td>
<td>Continue</td>
<td>tp</td>
</tr>
<tr>
<td>gotoIf</td>
<td>!${tp}</td>
<td>Common</td>
</tr>
...
<tr>
<td>label</td>
<td>Common</td>
<td></td>
</tr>
...
Wednesday, October 10, 2012
Test email deliveries on Rails
In config/environments/test.rb, set "config.action_mailer.delivery_method = :test". It tell action mailer not to deliver emails to the real world. Instead, emails will be accumulates in the ActionMailer::Base.deliveries array.
So, in email test, do something like:
test "should send email" do
assert_difference "ActionMailer::Base.deliveries.size" do
...
end
last_email = ActionMailer::Base.deliveries.last
assert_equal, ..., last_email.from
assert_equal, ..., last_email.subject
...
end
So, in email test, do something like:
test "should send email" do
assert_difference "ActionMailer::Base.deliveries.size" do
...
end
last_email = ActionMailer::Base.deliveries.last
assert_equal, ..., last_email.from
assert_equal, ..., last_email.subject
...
end
Saturday, September 29, 2012
Replace mechanize gem by selenium webdriver
Some years ago, the Mechanize gem was used by quite a lot of Ruby developers to exact web contents for testing or other uses.
However, the down side of Mechanize is that it cannot get delayed contents from AJAX. Selenium webdriver came to solve the problem.
The Selenium driver will launch a browser to simulate real user interaction with the target web site. So, the AJAX and other contents can be easily found using the selenium driver APIs.
http://seleniumhq.org/
However, the down side of Mechanize is that it cannot get delayed contents from AJAX. Selenium webdriver came to solve the problem.
The Selenium driver will launch a browser to simulate real user interaction with the target web site. So, the AJAX and other contents can be easily found using the selenium driver APIs.
http://seleniumhq.org/
Friday, September 28, 2012
Modern QA role on Agile SDLC
Most people in the industry are undoubtedly familiar with the Software Development Lifecycle (SDLC).
Reference: Wikipedia
I was having lunch with a recruiter colleague, and I was learning about the QA requests from lots of customers. Most defined the QA role well within the “Testing” oval as shown in the picture. From my questioning, it appears that the agile movement has done little to alter this SDLC. In fact, this process is still alive and very will, even within agile teams. The difference is in the batch size. Rather than doing analysis on a batch of 50 features and then moving that full batch to design, the agile movement has reduced that batch size considerably, and in some cases reduced it down to a batch size of 1. Lean agile teams are likely to use a batch size of 1 and continuously pull features through the lifecycle. As an aside, I find that even when working on a single feature, this cycle is still in play, although the feature is more likely to jump backward and redo a portion of the phase before if new information is found.
The reason for the reflection on QA is that my recruiter colleague still predominantly receives requests for QA folks to fill the roll of the testing phase. This means that the QA involvement happens after analysis, after design, after implementation, and only when defects can no longer be prevented. They can only be discovered. Inspectors at the end of an assembly line are powerless to prevent defective parts. They can only discover them through inspection and serve a Quality Control role to prevent defective parts from being shipped. The same is true in software, and many others have written the same.
I shared a very successful project where we incorporated what would otherwise be a very traditional QA Manager into an agile process and yielded great results and a very low defect rate. When crafting the team’s process, the QA Manager worked in between the analysis and design phases of a given feature to understand and then define the test cases. That is, based on the current understanding of the feature, how will we test it? The work required to create the test cases was sufficient to find analysis gaps early and force them to be filled. The additional information and context contained in the test cases added the design activity as well and yield, in my opinion, a more robust design that was less prone to defects of oversight. In this project, we saw the time spent coding reduced to less than 50% of the overall project effort. In fact, at the beginning of the project, programmers were about 50% of project staff, and half-way through, the programmer staff had been reduced to 1/3 of overall project staff. By crafting a process that pulled thoughts of QA to the beginning of the process, we modified the environment to one in which it was hard for defects to be created in the first place. In the end, we found no need to create a defect tracking database, and the team was applauded for its quality. The production launch, which always carries some risk, was a trivial affair, and the system is currently being used by many to perform their daily job.
Our industry stills see QA not as assuring quality, but merely controlling quality through inspection. Some savvy development managers already have changed traditional QA job descriptions, but there is a long way to go before these notions reach the mainstream of the industry.
What are your experiences with QA?
Thursday, September 27, 2012
Selenium driver find parent element
element.find_element(:xpath, "..")
Thursday, August 23, 2012
Use Mocha to stub a class method and raise an exception
$> gem install mocha
SomeClass.any_instance.stubs(some_method).raises(SomeException)
SomeClass.any_instance.stubs(some_method).raises(SomeException)
Friday, August 17, 2012
Check if a function is called in Rails unit test
required gem: mocha
some_object.expects(:some_function_name).[expected calls]
where
[expected_calls]
- .once - be call once only
- .never - should never be called.
- .at_most
- ...
Wednesday, July 18, 2012
Ruby on Rails development notes, tips, practices
Development
- Performance tuning tools:
- New Relic
- Useful tips:
- Use rails console to counter check the SQL statements being executed.
Testing
- Unit tests should be written in a way that adding new records in test fixtures shouldn't affect the previous test results.
- New test fixtures should be added in a way that they should link to existing fixture data so as to avoid breaking existing test cases.
Quality Assurance
- Besides unit, functional and integration test within rails framework. Create automated browser test using tools like "Selenium" over test/real data.
Maintenance
- Avoid using unnecessary code reflection. It's not good for performance and maintenance.
Sunday, September 28, 2008
CSUnit
What Is csUnit?
csUnit is a free and open source unit testing tool for the .NET
Framework. Unit testing is tightly associated with test-driven
development (TDD), refactoring, and other practices from agile software
development approaches such as Extreme Programming or Scrum.
http://www.csunit.org/
csUnit is a free and open source unit testing tool for the .NET
Framework. Unit testing is tightly associated with test-driven
development (TDD), refactoring, and other practices from agile software
development approaches such as Extreme Programming or Scrum.
http://www.csunit.org/
Friday, September 12, 2008
NUnit
What Is NUnit?
NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.6, is the seventh major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages.
http://www.nunit.org/
NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.6, is the seventh major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages.
http://www.nunit.org/
Subscribe to:
Posts (Atom)
