Continuous Integration with winIDEA and Jenkins

Overview
Create python script for test execution
Install Jenkins
Run headless tests as a service
Run tests with normal user account
winIDEA coverage in Jenkins

Overview

As the name implies, continuous integration (CI) requires running of tests repeatedly during the development cycle. This way we find problems soon after they appear, which usually makes fixing easier. Since repetitive tasks are better left to machines, server applications specialized for running build/test cycles were implemented. One of the most popular CI servers is Jenkins. To simplify CI process, winIDEA SDK enables running tests and displaying tests results with Jenkins:

Create Python script for test execution

To generate Python script for running tests headless from command line or Jenkins, use menu command iTools | Generate Test Script ...). The dialog opens, which contains the following configuration items related to Jenkins:

Install Jenkins

Jenkins home page provides download link and instructions for installation. If you're planning to show coverage results in Jenkins, install also Cobertura plug-in.

Run headless tests as a service

This section describes configuration of Jenkins to run testIDEA tests. Note, that test script can be generated with testIDEA, but it is also possible to write the script manually.

Important: Make sure you have specified path to iConnect.dll when generating script in testIDEA, or set environment variable.

  1. Create new project Enter project name and select Freestyle project, as shown in the image below.

  2. Configure the project

    Name of Test report XMLs (JUnit file) must be the same as name of test report configured in testIDEA, but with extension .junit.xml.

  3. Run the project Click Build Now in the menu, and wait for execution to finish. To observe progress, open console by double clicking the flashing icon next to build in the Build History box.

    Click the build number to get menu with build details, including console output and test result.

Run tests with normal user account

For debugging purposes it may be useful to run tests with account of logged user, not with Jenkins's account. In this case winIDEA window is visible. The test script uses preferences of the currently logged user for starting winIDEA, and winIDEA is not started as a service.

  1. Enable Java Web Start Open Top level menu | Manage Jenkins | Configure Global Security. Then select Enable security and Random.

  2. Create executor, which uses Java Web Start Open Top level menu | Manage Jenkins | Manage Nodes | New Node

    Click OK to get he next configuration screen.

  3. Select agent in project configuration

  4. Start executor agent In main dashboard, click node jwsGui in Build Executor Status box, to get the screen shown below:

    Connect the agent, then run the project.

Code coverage in Jenkins

To view winIDEA/testIDEA code coverage measurements in Jenkins, you can add link to HTML report created by winIDEA, or use Cobertura plug-in in Jenkins. The first approach provides more information, while the second approach provides quick overview of trends in graphical way. It possible to use both approaches in the same project.
If analyzer file from test case is used, it is very important to set value of Measure all functions in section Analyzer | Coverage | Statistics. If this check-box is checked, all code in the project is considered as 100% coverage. If it is not checked, only functions explicitly mentioned in the statistics section are considered as coverage goal (100% coverage).