9/19/2012

Hudson job running Selenium RC tests with TestNG Parameters

I really can recommend to execute tests under the testng framework. It provides optional parameters and execution of test suites in an easily understanding way and allows to modify the style of the reports through a css file. Optional parameters also allows you to run tests within Eclipse without setting them (then the default value is used, see below)For my Tests I used a superclass containing the “setUp” method, which is executed just before each testclass:
As you can see the parameters “seleniumhost” etc. are optional. If one of them isn’t set, then the default value is used, e.g. “localhost. You want to insert all your testclasses into your testsuite often named “testng.xml”. There you also can set values for the parameters: For running the testsuit testng.xml you just need to type "java org.testng.TestNG testng1.xml" into your command prompt. For the execution of your tests by hudson, you’ll need to create a new hudson job, build it once, then copy your tests into the established directory of the job (you’ll find it at usr/.hudson/jobs ) and write a ant file, which can be executed by hudson.
An Ant file has different targets, which can or can’t be executed separatly, sequential. You can define them in the hudson job configuration. Your ant file could look like this: For publishing results I can recommend to use testng-plugin and/or HTML Publisher Plugin for Hudson.

No comments:

Post a Comment