How to automate a test case?

Selenium automated testing in Openbravo ERP
Quality Assurance Webinar
April 8th, 2010
Agenda
•
Automated integration testing
–
–
–
–
•
10 minutes
What to automate?
Design
Stepping through code
Making an automated test for Openbravo
–
–
•
Selenium
Benefits
Other used tools
Selenium IDE
Automated integration testing in Openbravo
–
–
–
•
10 minutes
10 minutes
How to automate a test case?
Extend an existing test case
Q&A
30 minutes
Page 2
•
Automated integration testing
–
–
–
–
•
Automated integration testing in Openbravo
–
–
–
•
What to automate?
Design
Stepping through code
Making an automated test for Openbravo
–
–
•
Selenium
Benefits
Other used tools
Selenium IDE
How to automate a test case?
Extend an existing test case
Q&A
Page 3
Selenium
•
Selenium is a free software testing framework for web applications.
•
Selenium Remote Control - http://seleniumhq.org/projects/remote-control/
–
Allows to write tests in any programming language that can
make HTTP requests; using any mainstream JavaScriptenabled browser.
–
Consists of:
–
•
A server which automatically launches and kills browsers, and acts
as a HTTP proxy for web requests from them.
•
Client libraries for Python, Ruby, .NET, Perl, Java, and PHP.
Includes Selenium Core (the test execution framework) as its
engine and automatically loads it into the browser.
Page 4
Benefits
•
The testing suites can be executed daily, to check the most
recent changes.
•
It takes less time than a manual execution.
•
Spot errors that a human might not notice.
•
Prevent regressions.
•
Free staff to do other non-repetitive tasks and to look for
errors that a machine can't spot.
Page 5
Other used tools
•
Selenium IDE: a Firefox extension that allows to record, edit,
debug and play back tests.
•
Firebug: a Firefox extension that lets you inspect the HTML
file of a web page on an easy way. With it you can also edit
and debug the code of a page.
•
Xpath Checker: a Firefox extension that shows the XPath of
an element on a web page. In addition, you can write your
own XPath expressions and see the elements that match.
•
Ant: a software tool for automating software build processes.
•
JUnit: a unit testing framework for the Java programming
language.
•
Eclipse: Java/JUnit development environment
Page 6
Selenium IDE
Page 7
•
Automated integration testing
–
–
–
–
•
10 minutes
What to automate?
Design
Stepping through code
Making an automated test for Openbravo
–
–
•
Selenium
Benefits
Other used tools
Selenium IDE
Automated integration testing in Openbravo
–
–
–
•
10 minutes
10 minutes
How to automate a test case?
Extend an existing test case
Q&A
30 minutes
Page 8
What to automate?
•
Drivers and restrictions
–
–
–
–
–
–
•
Automation is a time consuming task.
Maintainability is an issue.
Only very stable flows should be automated.
Automated test cases have sense if executed at least ten times.
Only user-visible actions are performed
Javascript events could be missed by Selenium.
Our pick
– The Acceptance test
http://wiki.openbravo.com/wiki/Acceptance_Testing
Page 9
Design: General diagram
Test Suite
Test cases
Steps
Parameters
Selenium
Tests
Fields
Verifications
Test controllers
Expected
Results
1
Automated test cases
Screen definitions
Buttons
2
Links
Windows
Openbravo ERP
(Running in a web browser)
Page 10
Stepping through 1/2: Test controllers
Test cases
Steps
Verifications
Expected
Results
Parameters
Test controllers
•
Test controllers are closer to
Functional Test Cases
•
They know about common steps
•
Based in superclass
OpenbravoERPTest.java
Automated test cases
Page 11
Design: General diagram (Again)
Test Suite
Test cases
Steps
Parameters
Selenium
Tests
Fields
Verifications
Expected
Results
Test controllers
Automated test cases
Screen definitions
Buttons
Links
Windows
Openbravo ERP
(Running in a web browser)
Page 12
Stepping through 2/2: Screen definitions
Parameters
Fields
Automated test cases
•
Screen definitions are
closer to HTML pages.
•
They know about Fields,
Buttons, Links.
Screen definitions
Buttons
Windows
Links
Page 13
•
Automated integration testing
–
–
–
–
•
10 minutes
What to automate?
Design
Stepping through code
Making an automated test for Openbravo
–
–
•
Selenium
Benefits
Other used tools
Selenium IDE
Automated integration testing in Openbravo
–
–
–
•
10 minutes
10 minutes
How to automate a test case?
Extend an existing test case
Q&A
30 minutes
Page 14
How to automate a test case?
•
Document the scenario and execute it manually.
Visit Testlink at http://tools.openbravo.com:8891/testlink/
•
Understand the design.
•
Read the documentation and implementation of the main
classes.
•
Look for code that you can reuse.
•
Code missing screen definitions.
•
Write the test controller.
•
Test your test.
Page 15
Extend an existing test case – The screen definition 1/2
2
1
3
1
2
Page 16
Extend an existing test case – The screen definition 2/2
1
2
2
Page 17
1
Extend an existing test case – The test controller
1
2
2
1
Page 18
Extend an existing test case – The test controller
Page 19
Extend an existing test case – Creating the file
1
2
Page 20
Extend an existing test case – Running the test case
Page 21
Extend an existing test case – Results
Page 22
Wrap-up
•
Selenium is a powerful tool for tests automation.
•
Openbravo uses Selenium and other tools as part of its
Quality Assurance processes.
•
You can use those tools and the automation framework
provided by Openbravo to test your Openbravo ERP instances
and modules.
Page 23
More info
•
The source code is available at
http://code.openbravo.com/tools/automation/main
•
Ask your questions and give us your suggestions in
http://forge.openbravo.com/projects/automation/forum
•
The documentation is in the wiki
http://wiki.openbravo.com/wiki/Category:Automated_Testing_ERP
Pablo Luján
Arun Kumar
[email protected]
[email protected]
Leo Arias
[email protected]
elopio at #openbravo
on irc.freenode.net
Page 24
Next webinar: “Life Cycle Management”
April 22nd, 2010
IMPORTANT! Special time: 10:00 (CET)
Page 25
Q&A
Page 26