Rebar + Common Test + Jenkins

Testing is always important. This fact cannot be questioned. For Erlang, we have two excellent frameworks: EUnit and Common Test. I’m always using the latter, just because I’m used to it. I don’t know if it’s superior or inferior to the former (looking at EUnit suites I’ve seen, there are equally powerful, while CT is more conveniant to use). It does its job and that’s enough for me.

CT integrates with Rebar nicely (so does EUnit) and it can be run with rebar ct command.

Jenkins is a Continous Integration tool prepared for object-oriented languages, but it can be used with functional language, such as Erlang. To use it with CT, just run CT suites with Rebar in Jenkins job and if it fails/passes, the whole job fails/succeeds. It is just as simply as that. But it would be also useful to have a report on each test case embedded in Jenkins (“Status” menu) and this is something not provided out of the box.

Fortunately, the solution is very simple: just add the following line to your rebar.config:

{ct_extra_params, "-ct_hooks cth_surefire \"[{path,\\\"path/report.xml\\\"}]\""}.

And it will create a report that can be understood by Jenkins. Now enter job configuration and scroll down to “Post-build Actions”, the “Publish JUnit test result report” section. Provide the path to the report XML file you’ve just configured and there it is! A proper Jenkins + Common Test integration! šŸ™‚

Note: You can skip the path configuration and just write "-ct_hooks cth_surefire" and it will put the report in the logs directory but I usually prefer to put the report one or two levels up in directory structure.

This entry was posted in Development, Erlang and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s