Have you ever had that unit test that works locally, but fails on team city. Turns out you can debug them and find out that it isn’t team city’s fault.
You run the test locally, pass, run them on team city, fail. Alright, time to get serious, 1, pull the TeamCity artifact down locally, 2, run MSTest from command line like TeamCity does, 3, start debugging. Most unit test frameworks throw exceptions when a test fails, great way to debug into the test.
Make sure you have an artifact from TeamCity or you can’t pull down the test. Well, unless you are an admin on the box.
Open up Visual Studio Command Prompt for VS2015.
Next, attach to the MSTest process QUICKLY. MSTest launches QTAgent32.exe for running the actual unit tests but it won’t stop to wait for you.
In the end, it turned out another test ran first, and our second tests couldn’t set a private static readonly because of its if null check.
private static readonly List<int> Codes = new List<int>();