A series of short recipes for VSTS, VISUAL STUDIO and NUnit
I have had a need to have more easy access to information on how to do certain stuff, and have some easy access to simple code blocks, or templates, I can copy/paste. A blog post is for me somewhat more extensive, and that format was not really suited for smaller notes. So I decided to write them down as “recipes”, which is a small post, larger than a post-it, but smaller than a full blown blog post.
How to conditionally fail a build in a pull requests with TFS/VSTS
When your TFS/VSTS CI build is also used for a pull request, you often want to enable more checks before you let this go into the master (or any target) branch, and fail the build if these raise warnings.
It can be extra tests you want to run, code quality checks, process checks, and you might want to block the pull request if you have warnings from these.
Setting a single test task to fail could be done, but that only works well if you have a single step, with multiple tasks you will have build stops for one and every step, so it also reduces the error reporting granularity. And, it is nice to be able to see what is an absolutely blocker, red, and what is quality issues, yellow.
How to change test naming in Visual Studio using NUnit
The Visual Studio Test Explorer user interface have been nearly the same since 2012, with only a few minor updates. One thing that have annoyed a few people are how the test names are displayed. The Test Explorer have got a bit of critique on this, but it is not that hardcoded. It can be tweaked! With NUnit3 and the NUnit3TestAdapter version 3.8 you can configure this naming yourself, which makes for some interesting possibilities.
Test Data Retention policy added in TFS update 1
There has been an issue with growing databases due to test data and test attachments not being deleted. I have an earlier blogpost ( also here) on how to fix this, using a tool called Test Attachment Cleaner, and also containing a set of scripts you can run on your server to check on how your database sizes.
In TFS 2015 update 1 this was fixed by building a data retention policy in to the TFS. This works both for on-premises and for VSTS instances.
Visual Studio Testing Tools–Two new hotfixes released
Update: These have been superseded and included in later Cumulative Updates. See http://wblo.gs/cu8v for checking what you got and updates, or download the tool. Also see info about the updates and extensions here.
During the summer Microsoft has released two important hotfixes for the Testing tools. These two hotfixes solves 7 serious problems:
# | Issue solved | Fix in : |
1.1 | Appdomain error when running a test agent on a computer with Visual Studio installed | 1) |
1.2 | Exception with search error may happen on playback of a coded UI test on some WPF controls | 1) |
1.3 | OutOfMemory exception may occur when creating a work item from the Test Result pane. More frequent when TFS server has many builds. | 1) |
1.4 | Publishing of test results and builds stop responding for tests run in a build, due to a MSTest crash. | 1) |
2.1 | Test runner says “waiting for application under test” due to a crash when running a Manual test and you create a bug or run a test. | 2) |
2.2 | Unit tests fail to start after editing of testsettings when using batch files. | 2) |
2.3 | StackOverflowException occurs in Test Manager | 2) |
Note 1: KB2544407