Difference between revisions of "QA/test automation guide"
(→VCLAuto [Planning]) |
(→Code) |
||
Line 24: | Line 24: | ||
I found [[Test_Cleanup]] project starts to unify all testing code to follow the standard xUnit style, so I think it's time to clean up GUI test as well. | I found [[Test_Cleanup]] project starts to unify all testing code to follow the standard xUnit style, so I think it's time to clean up GUI test as well. | ||
− | == | + | == Getting Started with Eclipse == |
+ | |||
+ | === Setup Project === | ||
+ | |||
+ | 1. Import the following projects into eclipse workspace. | ||
+ | |||
+ | '''{AOO_SOURCE_ROOT}/testcommon''' | ||
+ | The project contains the common test utilities and low-level implementation to do GUI testing | ||
+ | |||
+ | '''{AOO_SOURCE_ROOT}/testscript''' | ||
+ | The project contains the GUI testing scripts. Test case should be written in this project. | ||
+ | |||
+ | 2. Open "testscript/build.xml", Run the ant target "prepare.dependencies" to get all required jars. Make sure you can access to internet. Otherwise, you need manually download junit.jar (MUST be 4.10+) into "testscript/output/lib/junit.jar" | ||
+ | |||
+ | 3. Refresh the test project | ||
+ | |||
+ | == Run Testing == | ||
+ | |||
+ | === Run Testing in Eclipse === | ||
+ | 1.Select a test class. e.g. testcase.SayHelloToOO | ||
+ | |||
+ | 2.Right click the SayHelloToOO and select Run As->JUnit Test. Create a JUnit configuration for the test class. | ||
+ | |||
+ | 3.Select Argument tab and add -Dopenoffice.home="C:\Program Files\OpenOffice.org 3\program" into VM arguments. | ||
+ | |||
+ | 4.Click Run to start testing | ||
+ | |||
+ | === Run Testing in Terminal === | ||
+ | Firstly make sure Apache Ant 1.8.2+ installed. In the terminal, run command "ant -version" to verify the version. | ||
+ | |||
+ | '''How do I run testing on my OpenOffice?''' | ||
+ | <source lang="bash"> | ||
+ | cd testscript | ||
+ | ant -Dtest.classes="[Your_Test_Classes]" -Dopenoffice.home="[Your_OpenOffice_Location]" | ||
+ | </source> | ||
+ | |||
+ | '''How do I run build verification testing after building AOO from source code?''' | ||
+ | <source lang="bash"> | ||
+ | source LinuxX86Env.Set.sh | ||
+ | cd testscript && ant | ||
+ | </source> | ||
+ | |||
+ | |||
+ | ''' Where to get the testing result? ''' | ||
+ | By default, the testing result is stored in "testscript/../testspace/output". | ||
+ | [[File:vclautoreport.png]] | ||
+ | |||
+ | |||
+ | == Write Testing Classes == | ||
Write UI testing case following JUnit 4 style like the following: | Write UI testing case following JUnit 4 style like the following: | ||
Line 75: | Line 123: | ||
click(200, 200); | click(200, 200); | ||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 08:18, 18 June 2012
Contents
VCL Test
Introduction
VCLAuto is a Java library for OpenOffice UI/functional testing like VCLTesttool. VCLAuto can be used with JUnit. The project is under developing and will be released in Apache OpenOffice 4.0.
There are a lot of testing codes in the OO project, e.g. unit test, qadevooo and smoketestoo_native. Why do we need the library?
Generally, unit test code (pure junit/cppunit test) is executed in the build process before OO is created. It's low-level and used to verify if the source code is right before they are linked to a real product. It's a white-box testing. If you want to verify a function/method/interface is correct, put your test code in unit test. qadevooo & smoketestoo_native uses UNO API/Macro to perform testing. To run them, a real OO product must be available. It's middle-level and used to verify if UNO api and business model work correctly. It's a gray-box testing. User interaction is not involved in this testing. It can't fully simulate a user behavior or check if GUI is correct. For example, check if user can draw a shape by dragging, check if OO automatically capitalize the first letter after typing a word, check if a button's checked when user change the selection, etc. Vclauto is high-level black-box testing. It performs testing more like a real user. It generates keyboard/mouse events, does GUI actions and gets information from the GUI to validate the function.
Background
Actually VCLAuto is a java version of VCLTesttool, which connects to the automation server (automation module) in OpenOffice with socket. With the "-enableautomation" argument, OpenOffice will start the server with listening on the port 12479 be default. VCLTesttool is heavily used by the QA team in SUN/Oracle, but many people doesn't like it because of its drawbacks.
- The poor IDE. (Java has many enough powerful IDEs to make writing code easily, e.g. Eclipse / Netbeans)
- Hard to debug.
- Hard to read the code and analyze the testing result. (A lot of code is written in Non-English. Maybe German)
- Too many errors
- Basic language is not popular.
I found Test_Cleanup project starts to unify all testing code to follow the standard xUnit style, so I think it's time to clean up GUI test as well.
Getting Started with Eclipse
Setup Project
1. Import the following projects into eclipse workspace.
{AOO_SOURCE_ROOT}/testcommon The project contains the common test utilities and low-level implementation to do GUI testing
{AOO_SOURCE_ROOT}/testscript The project contains the GUI testing scripts. Test case should be written in this project.
2. Open "testscript/build.xml", Run the ant target "prepare.dependencies" to get all required jars. Make sure you can access to internet. Otherwise, you need manually download junit.jar (MUST be 4.10+) into "testscript/output/lib/junit.jar"
3. Refresh the test project
Run Testing
Run Testing in Eclipse
1.Select a test class. e.g. testcase.SayHelloToOO
2.Right click the SayHelloToOO and select Run As->JUnit Test. Create a JUnit configuration for the test class.
3.Select Argument tab and add -Dopenoffice.home="C:\Program Files\OpenOffice.org 3\program" into VM arguments.
4.Click Run to start testing
Run Testing in Terminal
Firstly make sure Apache Ant 1.8.2+ installed. In the terminal, run command "ant -version" to verify the version.
How do I run testing on my OpenOffice?
cd testscript ant -Dtest.classes="[Your_Test_Classes]" -Dopenoffice.home="[Your_OpenOffice_Location]"
How do I run build verification testing after building AOO from source code?
source LinuxX86Env.Set.sh cd testscript && ant
Where to get the testing result?
By default, the testing result is stored in "testscript/../testspace/output".
File:Vclautoreport.png
Write Testing Classes
Write UI testing case following JUnit 4 style like the following:
public class UITest { @Before public void setUp() throws Exception() { initApp(); } @Test public void test() throws Exception() { // Create a new text document via main menu startcenter.menuItem("File->New->Text Document").select(); typeKeys("Hello OpenOffice"); writer.menuItem("Edit->Select All").select(); // Copy the text typeKeys("<$copy>"); assert("Text is inputted successfully.", "Hello OpenOffice", App.getClipboard()); } @After public void tearDown() throws Exception() { } }
The library mainly implements a bunch of vcl control proxies to perform actions on and retrieve information from OpenOffice. e.g.
VclControl startcenter = new VclControl("startcenter.id"); startcenter.click(); VclButton someButton = new VclButton("some.button.id"); someButton.click(); boolean checked = someButton.getText(); VclListBox someListBox = new VclListBox("some.listbox.id"); someListBox.select("Item1"); String selected = someListBox.getSelText();
Methods to post keyboard/mouse event to OS.
typeKeys("AB<enter>"); //type shortcuts typeKeys("<ctrl a><ctrl c><ctrl v>"); //Perform mouse click on screen click(200, 200);