Reporting OneTimeSetup Failures in TeamCity

TeamCity is a great tool for building a continuous delivery pipeline. Every team that I’ve worked with at Pluralsight uses this tool and seems to enjoy it. However, we do hit snags occasionally and today was no exception.

We discovered a build today that has been failing silently for the past few weeks. The build was failing while executing some acceptance tests, the failure was due to misconfigured credentials. The surprising part here is that the failure was not being reported – the build showed green and was allowing the product to make it’s way into production. Thankfully this was a build-server specific issue and not something that had customer facing impact in production.

It turns out that the tests were failing in a NUnit OneTimeSetup method. This failure was not being reported by TeamCity. After some digging we found the issue – a bug in our version of NUnit (3.2.1).

The fix is simple, upgrade (or downgrade) NUnit and you are on your way. If you take the downgrade path, there is another issue you should be aware of. Older versions of NUnit do not report OneTimeSetup method output in the TeamCity build log. This becomes painful if you are trying to diagnose a failure that is happening in one of those methods. I think your best bet is to upgrade to NUnit 3.4 or greater.

In summary:

NUnit older than 3.2 does not report OneTimeSetup method output in TeamCity.

NUnit 3.2 does not fail tests in TeamCity that fail in the OneTimeSetup method.

Nunit 3.4 and greater seems to be the best choice.

265 Words

2017-10-11 06:00 +0000