0
votes

I've got a TeamCity build configuration with two steps currently:

  • MSBuild
  • Execute powershell sciprt

I want to add another one:

  • Run QUnit tests

Inside Visual Studio I use Chutzpah to run my QUnit tests. It seems that there is no "Runner type" appropriate though for QUnit tests, and because I do see one for NUnit I'm left wondering if I'm looking at this right.

Should I get a TeamCity extension to add a "Runner type" for QUnit tests? Should I create a powershell script that runs chutzpah-console? And if so how should I make sure the test output is picked up by TeamCity (do I need the /nunit2 or /junit flag?)?

I've done some research, allow me to share...

I've applied my Google-fu but that leads to a blog post with complicated QUnit tests with special TeamCity messages (or perhaps I misunderstood?) and a blog post on using a command-line build step to call PhantomJS that uses a rather contrived html file that seems like overkill to me if I'm already using Chutzpah in Visual Studio anyways (or perhaps I misunderstood)?

I've gone through the Chutzpah Full Documentation but as far as CI goes it only has a section on TFS Build, nothing on TeamCity or CI in general. I've carefully looked through the command line options documentation, and it does have one relevant option:

/teamcity     :Forces TeamCity mode (normally auto-detected)

This suggests that you normally don't need to do anything to get things working, but that's certainly not the case: my sln (or better: csproj) contains several js files with QUnit tests, but TeamCity shows no tests.

So, how do I get TeamCity to run QUnit tests in the (c)leanest way possible / how do I use Chutzpah in a TeamCity build step?

1
Well, I found the answer when nearly done writing up my question. Guessing it's probably best if I post anyway and share my solution as a self-answer, regardless of how obvious it may be to some (AFAIK this answer wasn't out there / easy to find yet). - And perhaps someone will chime in with an even better solution!?Jeroen

1 Answers

2
votes

No need for "service messges" or custom html files that go into a special PhantomJS call if you're already using Chutzpah. Here's one (other) way to do it in a (c)lean way.

There is no specific runner type for this type of build step. But no need for a custom Powershell script either: it'll be one line of script only. You can just use a Command Line step to invoke Chutzpah. To be more complete, assuming you've got TeamCity running already on a Windows machine, follow these steps:

  1. Install chutzpah.console.exe. The easiest way is probably using chocolatey to install the Chutzpah package using this command in Powershell:

    choco install chutzpah
    

    This installs Chutzpah and makes sure the exe is in your path (you may need to reboot TeamCity parts to get this noticed!).

    Note that alternatively you could also manually get chutzpah.console.exe on your CI server somehow (e.g. grab it from your dev machine) and reference it with a full path or place it in your path yourself.

  2. Add a Command Line build step with a custom script like this:

    chutzpah.console.exe "MyProject/UnitTestsSubDir"
    

    E.g.:

    Build step configuration in TeamCity

And by some black magic this is all it takes: your tests will be run (see the build log) and TeamCity will pick up the test results.