Atlassian Plugin SDK - how to provide optional selenium tests21 Feb 2011 Tags:
I don't want to read all this, give me the code
You could find all the code you need on github.
Sorry for not embedding all the code in the article. That way the article becomes clumsy unreadable monster. If anyone could recommend me some collapsable/expandable solution - I would appreciate it a lot.
Why do I need to bother with yet-another-testing-tool? The main advantages or features of the tools are (imo):Lucky to us, selenium has maven artifacts available to be used to plug-in into Atlassian PDK build procedure. Goals:
- real UI behavior testing - tests are run inside the real browser and will fire/use real end-user key, mouse, etc events
- ability to export the test in whole bunch of programming languages (java, python, ruby etc ...)
- ability to run tests on multiple target web-drivers (firefox, internet explorer, etc ..)
- Selenium IDE (mentioned earlier) is really nice tool which allows to create simple tests cases very fast, in few minutes or even seconds, literally
- basically the only way to automate difficult Ajax/RIA component testing on different target environments; other httpUnit like approaches are not good enough
Selenium RC comes in two parts.
- A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
- Client libraries for your favorite computer language.
- make this optional (enabled by default) option
- selenium-rc server side should be forked before integration tests will be executed
- selenium-rc client side tests should be executed as part of the integration test suite
- selenium-rc should be revoked upon integration-test completion
- is achieved by default maven profile (activated by !property)
- is achieved by maven - specifying selenium-rc start-server goal to be run on pre-integration-test phase
- to achieve this please refer to Atlassian article - Writing Integration Tests. Basically that means - you should put your code inside src/test/java/it/ folder and specifying proper locatest.properties file.
- is achieved by maven - specifying that selenium-rc stop-server goal should be executed on post-integration-test phase.
Benefits:Problems with Continuous Integration Ok, so we think we have automated our process so far and it runs locally. On my machine it launches internet explorer and executes the test. Awesome. The next thing is putting the test on our CI, which should be pretty straightforward, right? Wrong! Problems with CI:So, as a result we have completely independent sets of integration/functional tests, with ability to launch them all-together or pick just one of them.
- ability to reuse utility methods (such as create new custom fields, restore from xml dump etc ..)
- ability to configure your Selenium test against jira integration test environment - using helper to obtain JiraEvironmentData's host, port, context path etc..
Unlucky I'm not able to share that piece of code, so you should to create it on your own. Still, it should be pretty straightforward, since all you need to do - is do declare member field and delegate to is in your test setUp/tearDown, as well as using it to configure your Selenium test host, port etc ..
- CI slave might be Linux terminal machine, no UI and therefore no real launch browser capabilities.
- There is a bug with previous pom.xml file. Yes, the profile is optional, however Atlassian PDK framework execute all the it/ tests regardless what type of tests are they, therefore all the Selenium tests will fail.
The former one is solvable by using Selenium-RC Headless X11 with XVFB maven goal. The solution is to execute the goal on Linux machine and skip one on a Windows box. That could be achieved by additional profile setting xvfb skip flag to true and activated on windows platform only.
The later one could be solved by specifying AMPS plugin testGroups. Using that we could specify different sets of independent functional tests, located in different locations (it/functests* and it/selenium/*). We could use configuredTestGroupsToRun property as well, but I decided not to.
Please see updated_pom.xml file.
NB. If you've found typos or errors, please suggest a correction or edit on github.