Tests Reports are of course an important part of any automation framework. While most (all?) test runners and languages will provide a Junit output that can be parsed easily by CI tools (including CircleCI), it can be useful to add other types of reports that may be getting generated as part of a test run.
One popular reporting tool that I've personally been using for years is Allure
Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what has been tested in a neat web report form but allows everyone participating in the development process to extract the maximum of useful information from the everyday execution of tests.
Allure comes with multiple framework support, so we'll not cover the generation of the report here, but assuming you are able to generate allure results locally, here are the steps you can take to attach a generated allure report as an artifact as part of Continous Integration job.
How to attach the report
There are multiple ways to install Allure, depending on the machine or image being used. We are using a node image so we just do a global install with npm.
sudo npm install -g allure-commandline
Generating the report
To generate the report, you will need Java installed and configured. We are using a prebuilt node image, and then to be able to run our WebDriverIO tests, we are appending -browsers to that pre-built node image. Our image now has Java 8 installed and configured.
Generating the report is as follows:
allure generate --clean
The step in your CircleCI config will look like this:
run: name: generate allure report command: | sudo npm install -g allure-commandline allure generate --clean when: always
You may also want to have the Allure Report display some branch and commit information. The step would then look this:
run: name: generate allure report command: | sudo npm install -g allure-commandline echo BRANCH=development >> allure-results/environment.properties echo COMMIT=$CI_PULL_REQUEST/commits/$CIRCLE_SHA1 >> allure-results/environment.properties allure generate --clean when: always
Now that we have generated the report, the final step is to attach the Allure Report as an artifact.
- store_artifacts: path: /home/circleci/project/allure-report
You can now navigate to the artifacts tab and click on the link ending in index.html
Did you find this article valuable?
Support Hugh McCamphill by becoming a sponsor. Any amount is appreciated!