XML Reports for Erlang Common Test Runs
Within our Continuous Integration process, we heavily depend on running tests using Erlang's excellent Common Test (CT) framework. With CT's help we not only can run tests in a moderately distributed fashion, but more importantly we have plenty of options to run subsets and different combinations configuration options in a really easy way.
But there always was one downside: those tests didn't show up in Hudson. Although CT generates nice HTML logs of the test runs, the only way of CT integration in Hudson was to use an error return code to signal failure. But what is typical for the XML reports, like finding changes in the number of tests executed for verification of the test process, runtime of test cases for finding performance degrations, etc. is not possible within the CT framework.
To ultimately solve this Hudson integration issue, we have published a tiny library called ct_surefire which by pure erlang means parses CT logfiles and generates XML reports from them that can easily be integrated in CI process such as Hudson.
How you can integrate ct_surefire in your CI process
[Disclaimer: I assume you are using rebar for building your Erlang project. If you don't, well, you should. It's an excellent tool.]
Integration of ct_surefire in your build process goes along 2 easy steps
- add ct_surefire to your rebar.config
- run ct_surefire in your CI rule(s)
1. Add ct_surefire to your rebar.config
In the rebar.config in the root directory of your project, add ct_surefire to your deps section: (update version tag accordingly)
{deps, [
...
{ct_surefire, "0.3", {git, "git://github.com/zeitgeist/ct_surefire.git", {tag, "v0.3"}}
...
]
}2. Run ct_surefire to generate the XML reports for your
ct_surefire will look in the logs/ subdirectry of your project's root directory for CT logfiles by default. That is, when you run CT with logs enabled, point its "logdir" Parameter to $PROJECT_ROOT/logs
To then generate the report, you just have to call ct_surefire this way:
make -e -C deps/ct_surefire xmlify REPORT_DIR=${REPORT_DIR}That's it! with ${REPORT_DIR} you can overwrite the place where ct_surefire will write its XML files. For each application under test, a dedicated XML file will be generated. Therefore let REPORT_DIR point to the directory, where you collect all the surefire XML reports.
3. Point Hudson / your CI server to ${REPORT_DIR}
To complete the integration, point e.g. Hudson's surefire XML plugin to ${REPORT_DIR} and be done.