Jenkins

You can use your tests in Jenkins.

All you have to do is create a new job and add a build step to run a shell command. First use Add build step and select shell.

Using htf command-line-utility

The easiest way to run your tests is to put them all into a folder called tests/ and then add the following in your buildstep

htf --html_report=testreport.html --junix-xml-report=results.xml tests/

Using a shell-script

If you have many tests or only want to run specific tests htf command-line-utility could also do this job. But you would have to edit the Jenkins job all the time. Or maybe you want to run tests in a specific order.

A better way is to write a shell-script (eg. run_tests.sh) that runs htf with the tests to be run.

Enter the following in your build step

run_tests.sh

and put

#!/bin/bash

htf --html_report=testreport.html --junix-xml-report=results.xml test1.py test2.py

into run_tests.sh.

Using a python-script

You can also create a python script (eg. run_tests.py) that is run within the build step.

The shell command should be a call to the Python-interpreter python or python.exe followed by -u to enter unbuffered mode and followed by the script name.

python -u run_tests.py

Make sure the environment variable $PYTHONPATH is set correctly. If you need distinct workspaces $PYTHONPATH (and other environment variables) can be set using the EnvInject-plugin.

An example script could look like:

from __future__ import \
    absolute_import, division, print_function, unicode_literals

import htf

if __name__ == '__main__':
    tests = [
             "tests.example.ExampleTestCase1",
             "tests.example.ExampleTestCase2",
             "tests.example.ExampleTestCase3",
             ]

    htf.main(title="An example test for Jenkins",
             tests=tests,
             html_report="testreport.html"
             junit-xml-report="results.xml")

Using XML-reports in Jenkins

Jenkins can use the XML-testreport with xUnit-plugin or the JUnit-plugin.

Use "Add post build action". Select "Publish xUnit results". Select add and select "JUnit" and enter "*.xml" for example.