Last modified by Ecaterina Moraru (Valica) on 2017/09/04 14:50

<
From version < 67.1 >
edited by PaulIosifGuralivu
on 2008/08/05 09:23
To version < 68.1
edited by Ecaterina Moraru (Valica)
on 2017/09/04 14:50
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.PaulIosifGuralivu
1 +xwiki:XWiki.evalica
Content
... ... @@ -4,7 +4,7 @@
4 4  
5 5  The first part of the tutorial explains how to record tests scenarios using the Selenium IDE firefox extension. The second part deals on how to translate these scenarios to actual Java tests cases that can be integrated in a distribution-test module of a XWiki product.
6 6  
7 -The tutorial take a test on the rollback feature of XWiki as an illustration. To get more examples, tests can be found under the */distribution-test/selenium-tests/* directory of each XWiki product, for example [here>http://fisheye2.atlassian.com/browse/xwiki/xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests] for XWiki Enterprise.
7 +The tutorial take a test on the rollback feature of XWiki as an illustration. To get more examples, tests can be found under the */distribution-test/selenium-tests/* directory of each XWiki product, for example [here>http://fisheye2.atlassian.com/browse/xwiki/xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests] for XWiki.
8 8  
9 9  #toc("" "" "")
10 10  
... ... @@ -51,7 +51,7 @@
51 51  
52 52  Now with this record, we have a good idea of what our final test should consist of. The next step is to translate it as java code, so that it becomes part of the build process and can be ran on continuous integration servers. XWiki uses the maven selenium plugin to start and stop the [Selenium Remote Control>http://selenium-rc.openqa.org/] server.
53 53  
54 -XWiki wraps the selenium API for its own needs, and offers a test framework on top of it to facilitate XWiki product testing. For our rollback test, we can extend the *AbstractXWikiTestCase* from the *com.xpn.xwiki.it.selenium.framework* package of XWiki Enterprise *distribution-test* module. We will ensure our test runs authenticated by calling the loginAsAdmin() method in the setUp() of the test. Then we can write a testRollbackToFirstVersion() that reproduce the actions we have recorded with the Selenium IDE :
54 +XWiki wraps the selenium API for its own needs, and offers a test framework on top of it to facilitate XWiki product testing. For our rollback test, we can extend the *AbstractXWikiTestCase* from the *com.xpn.xwiki.it.selenium.framework* package of XWiki *distribution-test* module. We will ensure our test runs authenticated by calling the loginAsAdmin() method in the setUp() of the test. Then we can write a testRollbackToFirstVersion() that reproduce the actions we have recorded with the Selenium IDE :
55 55  
56 56  {code}
57 57   public void testRollbackToFirstVersion() throws Exception
... ... @@ -115,9 +115,9 @@
115 115  }
116 116  {code}
117 117  
118 -We can the run our test typing "mvn install -Dpattern=VersionTest" under distribution-test/selenium-tests/ in XWiki Enterprise sources. Running the test will actually launch the Selenium Remote Control, that itself will execute the test live in a browser you will be able to see.
118 +We can the run our test typing "mvn install -Dpattern=VersionTest" under distribution-test/selenium-tests/ in XWiki sources. Running the test will actually launch the Selenium Remote Control, that itself will execute the test live in a browser you will be able to see.
119 119  
120 -We still need to add it to the test suite of XWiki Enterprise, so that it is executed along with the other existing tests when performing a distribution test. We do so editing the AllTests class :
120 +We still need to add it to the test suite of XWiki, so that it is executed along with the other existing tests when performing a distribution test. We do so editing the AllTests class :
121 121  
122 122  {code}
123 123  public static Test suite() throws Exception
... ... @@ -146,7 +146,7 @@
146 146  WaitForCondition() gives you access to a object called selenium(you can find the api in file selenium-api.js or [here>http://svn.openqa.org/fisheye/browse/~raw,r=2100/selenium/trunk/src/main/resources/core/scripts/selenium-api.js]). Selenium object also gives access to an other object called browserbot(selenium.browserbot - api can be found in file selenium-browserbot.js or [here>http://svn.openqa.org/fisheye/browse/~raw,r=2100/selenium/trunk/src/main/resources/core/scripts/selenium-browserbot.js]). With the function *page()* the html page is return(including the head section) and with *bodyText()* we receive only the body section of html page. The function indexOf() search for the text into body text. While this condition is false waitForCondition() will re-execute the Javascript snippet until the condition is true or the 2 seconds are gone.
147 147  
148 148  An other example:\\
149 -In XWiki enterprise there is a section where you can see all the files(of XWiki application) in a table. There are some filters after page, space and last author. If you type one letter into page filter, files whom contain that letter will appear into the table. While testing into selenium this feature isn't enough to just type the letters into the form, you also have to refresh the element that loads the table according to the filter. In our case in ajax-loader.
149 +In XWiki there is a section where you can see all the files(of XWiki application) in a table. There are some filters after page, space and last author. If you type one letter into page filter, files whom contain that letter will appear into the table. While testing into selenium this feature isn't enough to just type the letters into the form, you also have to refresh the element that loads the table according to the filter. In our case in ajax-loader.
150 150  
151 151  {code}
152 152   private void fillTableFilter(String field, String text)
... ... @@ -164,7 +164,7 @@
164 164  #error("Avoid dependencies between tests")
165 165  
166 166  *For example:*
167 -If I test Scheduler feature from XWiki enterprise. In one test method I could create a Job for scheduler. And in the next one I can assume that the Job exist in Scheduler's Job List and start testing the edit/delete functionality of the Job. There is a high probability that the test will fail, because the second test depend on the first one. But what if the order of execution for this test is changed and the second one gets to be executed before the first one ? Then the test will fail.
167 +If I test Scheduler feature from XWiki. In one test method I could create a Job for scheduler. And in the next one I can assume that the Job exist in Scheduler's Job List and start testing the edit/delete functionality of the Job. There is a high probability that the test will fail, because the second test depend on the first one. But what if the order of execution for this test is changed and the second one gets to be executed before the first one ? Then the test will fail.
168 168  
169 169  {code}
170 170  public void testCreate()

Get Connected