Bootzooka Iteration 11: project rename and Jasmine tests visibility in TeamCity

26 Mar 2013.2 minutes read

So, as you probably already know, we have picked the winner in our “better name for Bootstrap” contest. Our beloved open source project is now called Bootzooka. So in this iteration the main visible change was to find every old name usage and replace it with Bootzooka. And as you can see below, everything, even url is now bootzooked ;)

Bootzooka Iteration 11: project rename and Jasmine tests visibility in TeamCity

Jasmine tests visible in TeamCity

Another change, less visible to users, but very crucial for application developers is a small extension in sbt jasmine tests runner that allows to report results of JavaScript tests to TeamCity. With this feature our tests are listed next to Scala unit tests and we can check their status: failure or success without diving into build log:

Bootzooka Iteration 11: project rename and Jasmine tests visibility in TeamCity

Plugin modification internals overview

TeamCity has a very cool feature: when it executes each build, it also checks build log file for some specific patterns and then, when pattern is detected, TC executes corresponding action. In our case we are going to use “Reporting Tests” functionality (check TC documentation for more details) that allows to add information about executed tests. So what our plugin extension will do on each test start, failure, success and finish is to print specific string to the build log so TC could detect it.

Implementation details

Now, when we know what should be done, the only thing left is the actual implementation. The first problem is to find the way to execute specific action on different test events. Luckily Jasmine has JsApiReporter with methods suited exactly to our needs.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
reportRunnerStarting: function(runner) {
  // here we will print test suite started message
},
 
reportRunnerResults: function(runner) {
  // here we will print test suite finished message
},
 
reportSpecResults: function(spec) {
  // here we will print:
  // 1. test started message
  // 2. if(test.passed) {
  //   print test passed message
  // } else {
  //   print test failed message with description of the problem
  // }
  // 3. test finished message
}

Next thing is to inform Jasmine tests runner that our custom reporter exists and wants to be notified about test execution events. This can be achieved pretty easily with this one-liner:


1
jasmine.getEnv().addReporter(new TeamCityReporter());

After that everything is more or less ready. If you want to see full commit with this extension, please check our company Github. We have also created a pull request to the original sbt-jasmine-plugin project and maybe it will be merged into the core.

How it looks in Bootzooka

After we replaced original sbt-jasmine-plugin with our custom made solution, all Jasmine tests are listed as a separate test suite:

Bootzooka Iteration 11: project rename and Jasmine tests visibility in TeamCity

And when any tests fail, we could see what went wrong without examining build log file:

Bootzooka Iteration 11: project rename and Jasmine tests visibility in TeamCity

Summary

As you can see, Bootzooka is constantly growing and evolving. You can always check its live demo on bootzooka.softwaremill.com, browse source code on GitHub or subscribe to our RSS to keep in touch with latest news.

Blog Comments powered by Disqus.