Running BDD tests from TestLink in Jenkins

Last night and this morning I spent some time working on running BDD tests that were created in TestLink in Jenkins, using testlink-plugin.

Similar integration has already been proposed in JinFeng, by Olivier Renault. Basically, you write BDD stories in TestLink (a story goes into the Test Case summary), Jenkins retrieves these stories and executes them using a skeleton project.

There are many ways to use BDD. In some of them you write code like Java, Ruby or Perl, and in others you write a DSL. I started working with JBehave, but for this integration, I preferred to use a DSL - as TestLink doesn’t maintain source code, only test cases -, so I switched to easyb.

There are many pros and cons in this integration, and a lot of work to do in the existing BDD tools, in TestLink and in the testlink-plugin too. I will write more about it in details later, but here’s a short list of things I’ve noted to work on the integration:

echo $TESTLINK_TESTCASE_SUMMARY | perl -pe 's|\<br \/\>|\n|g' | perl -pe 's|\<br\/\>|\n|g' | perl -pe 's|\<\/div\>|\n|g' | sed -e 's/<[a-zA-Z\/][^>]*>//g' | perl -MHTML::Entities -le 'while(<>) {print decode_entities($_);}' | perl -pe 's|^\s+||' | perl -pe 's|\xA0||g' > "$TESTLINK_TESTCASE_EASYB_FILENAME.story"

I’m working on a [Plug-in API proposal]({% post_url 2012-10-25-a-quick-view-on-wordpress-mantis-and-jenkins-plug-in-api %}) for TestLink, and I can already imagine a few places where we could use a plug-in and that would help in the BDD integration.

A test case could use a plug-in to retrieve its content from a git repository, for instance. So the BDD could be stored/versioned in GitHub, and written in any language. And it would be displayed by the plug-in as if it was the Test Case summary in TestLink.

You can get the idea of the integration from the screen shots in this post. The source code for the skeleton project is available in this repository - I used the examples from easyb website.

Categories: Blog

Tags: Testlink, Jenkins, Software Quality