Integrating LeanFT with Jenkins—in just a few simple steps

OriBendet
Visitor.
6 2 12.9K

 

(This post was written by Yossi Rachelson and Aviad Diamant from the LeanFT R&D Team)

 

Lean Functional Testing (LeanFT), is a new functional test automation solution, targeted to advanced automation engineers and dev-testers in agile team, built specifically for continuous testing and continuous integration.

In this blog we’ll see how to integrate LeanFT with Jenkins, one of the most popular continuous integration systems.

In few simple steps, you can configure your Jenkins server to run LeanFT tests on every build.

 

Try LeanFT for yourself to experience this integration capability.

 

You can easily present a link to the LeanFT’s automatically-generated run report (html), for each of the builds, directly in the Jenkins interface:

 

Prerequisites for a successful integration:

  • Have a basic familiarly with Jenkins
  • An installed Jenkins server
  • An installed LeanFT runtime engine
  • An installed unit testing framework runner (NUnit orJUnit)

Note: Jenkins enables configuring machines as slaves, such that the Jenkins server itself will only do the orchestration, and the actual job (e.g.: running the tests) will be done on these slave machines. In this case, the LeanFT runtime engine and testing framework runner, should be installed on the slave machine as was configured in Jenkins. For simplicity, in this blog post we assume that everything is installed on the same machine, which is also the Jenkins server machine itself.

 

A step-by-step guide

A typical flow of integrating LeanFT with Jenkins, is composed of the following steps:

1. Create a LeanFT testing project in your IDE, based on the LeanFT’s project template for that IDE:

LeanFT NUnit Project in Visual Studio

LeanFT JUnit Project in Eclipse

 

2. In the project, create your tests using the LeanFT SDK and the various tools provided by the LeanFT IDE plugin (e.g.: The Object Identification Center and Application Models)

3. Build and run your tests locally. Check-in the source code (e.g.: to SVN)

4. Create a new job in Jenkins

5. Configure the job to run your LeanFT tests

For LeanFT-NUnit testing projects:

Add a build step to run your tests using the NUnit runner:

A new command textbox will appear in the configuration. Type inside the command which runs your tests using the NUnit runner:

The command should look like:

"C:\<NUnit folder>\bin\nunit-console-x86.exe" "%PATH_TO_TEST_PROJECT_DLL%\DLLFileName.dll"

Where the first command’s part points to the NUnit runner file and the second part to the path of the dll(s) which is the output of building your testing project(s).

From this point on, whenever you run the job, your LeanFT tests will be run and the NUnit results file will be generated. Now, wasn’t that easy? 🙂

Notes:

NUnit exposes a few more parameters that can be used when running testins from the command line:

        • /runlist="\RunList.txt"- can be used in case you'd like to run only specific tests from the above dll. The text file should include the list of tests to run
            • /result="% \RunResults.xml" can be used if you want the name and location of the results file created by NUnit, to be different than the default

For any information about running NUnit from command line – see NUnit-Console Command Line Options on the official NUnit help site.

It is recommended also to install the NUnit Jenkins plugin. When the plugin is installed, Jenkins presents direct links to the NUnit results file for each build, as well as some very useful trend graphs

 

For LeanFT-JUnit testing projects:

For the case of JUnit, you should use the following command:

java -classpath ".\com.hp.lft.sdk-12.51.0-standalone.jar;.\ com.hp.lft.report- 12.51.0.jar;.\ com.hp.lft.unittesting-12.51.0;.\{testsJar}.jar;.\junit-4.12.jar;hamcrest-core-1.3.jar;" org.junit.runner.JUnitCore junitClass

To have the job reflecting the real run status and generating the JUnit report, you can run the tests using Ant (another option is using Maven). You can read about Ant here: https://ant.apache.org/manual/Tasks/junit.html

To do this, add a build step called “Invoke Ant”:

In the step’s parameters, enter the following:

  • “Targets” should contain the relevant Target from the Ant build file
  • “Build File” field should contain the path the Ant build file

The Ant build file contains relevant Jars and their locations, test names and path to JUnit report to be created in.

 

6. Configure your job to present a direct link to the LeanFT run report, for each build:

Whenever LeanFT tests are being run, LeanFT automatically creates a rich HTML run report, which reflects the execution of all of these tests, along with useful information such as stack trace (in case of failures) and screen captures of the application under test.

You can easily configure your job, such that for each build, a link to the LeanFT run report for that build, will be presented directly in the Jenkins interface.

LeanFT generates the run report files (html and screen capture files) into a pre-defined location in the file system. You can change this location, by editing the app.config file (for NUnit test projects) or the properties file (for JUnit test projects), which are deployed with your testing project’s output dll / JAR:

You can configure your job to copy the created report files from the configured location (or default location if you don’t change it), to wherever you like. It is recommended, however, to copy the files to your job’s Workspace. Every job in Jenkins has a “workspace” which can be used to store useful files which are generated while running the job. To copy the LeanFT report files to your job’s workspace, perform the following:

1. Add a build step of “Execute Windows batch command”

2. In the textbox which appears when adding the build step, type the following commands:

move "{ReportDirectory}\RunResults\runresults.html" %WORKSPACE%

move "{ReportDirectory}\RunResults\Resources " %WORKSPACE%

  • “ReportDirectory” is the “target-directory” configured as the report’s root folder above
  • “RunResults” is the default name of the folder created by LeanFT to contain the report files (as appears in the above configuration)
  • The first command copies the report html file to the “workspace”
  • The second should be used if your project was configured to create screens captures for its report, in which case these files should be copied to the workspace as well

Now, when running your job, you will be able to see the LeanFT report files in the job’s workspace:

 

The workspace stores files per job. To have the report files for each build of the job separately, you should add a post-build action in your job’s configuration, which archives the files, per build:

Then, to instruct Jenkins to archive all the files in the workspace, type “*.*” in the textbox:

 

Now, when running your job, the LeanFT report files will automatically be copied to the build’s artifacts:

The last step would be to configure the job to present a nice link to the report, per build:

To make this magic happen, you should first install the Jenkins Groovy plugin. Groovy is a useful Jenkins plugin, which provides several options for configuring the Jenkins UI. After installing the plugin, you need to add in the job’s configuration a new post-build step, named “Groovy Postbuild”:

Then, in the textbox, add the following line and save your project:

manager.addBadge("info.gif", "LeanFT Report" ,manager.build.getAbsoluteUrl()+'artifact/RunResults.html')

This command will add for each build an icon (“info.gif”. No need to provide the icon itself as it is built in with Groovy”), having the tooltip of “LeanFT Report”, which links to the html report that was copied to the build’s artifacts:

 

Outro

Developing software applications using continuous integration (CI) methodologies, includes integrating with a CI system for application testing, which is triggered automatically in a certain frequency or per event (e.g.: checking in a change in the application). LeanFT was built specifically to support CI scenarios, and as a result, a natural and easy integration with the common CI systems is expected.

In this blog we saw how easy it is to configure Jenkins, one of the most common CI systems, to run LeanFT tests and present the run report directly in its interface.

You can read more about LeanFT, in the LeanFT Help Center.

Good luck!

 

Thanks to Yossi and Aviad for providing this article!

Try LeanFT for yourself!

 Feel free to leave a comment in the box below.

2 Comments
Brad Korber
New Member.

Great write up.  I wish our FT licenses got us LeanFT licenses, but since they are not full UFT licenses we cannot.  Hopefully someday we can upgrade and get automation like this from build to verification, not just in integrated acceptance testing.

Absent Member.. TechnicalTester Absent Member..
Absent Member..

Having seen a live demo of this at Discover I'm keen to try and get a PoC demo together within our company, however I don't think we even use Jenkins but I can at least point the dev folk in the direction of this great article.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.