Rerunning all Unit Tests with Different UI Culture

I was recently made aware that some unit tests for Kentor.AuthServices were failing on non-English computers. To handle that, I set up an Azure VM with Swedish installed and made a special unit test that would run all other tests with different UI cultures.

When I first understood that I had tests that were broken when run on non-English computers I of course felt that it should be fixed. The tests should not only run with other languages to enable developers from other countries. The tests should of course be possible to be run and used to find problems if someone reports errors on computers having a special language installed. There’s quite a few places in the code with string formatting and it can differ with different cultures, causing hard to find problems.

What I did was to write a special unit test that finds all other unit tests in the code and runs them with different UI culture. The unit tests are found using LINQ and Reflection (it’s an awesome combination that’s extremely powerful) and then they are run with reflection.

Add a Language to Windows Azure Visual Studio VM

I was recently made aware that some unit tests for Kentor.AuthServices were failing on non-English computers. To be able to test a different setup I turned to Azure and set up a machine with VS2013 Pro and installed Swedish language support. Once I found the right way, it was very straight forward.

The problem was that I had set up a number of unit tests to check the actual contents of the exception message. Those are customized when running on a different UI culture (if the language is installed).

Just checking the type of the exception would not be enough as some methods throw ArgumentNullException for different parameters and I want to make sure that it is the right param that is detected and not a false positive. Following the TDD practices as strictly as possible on this project I had to get failing tests first, before making any changes.

I also wanted to make sure that it’s possible to develop and run all tests on VS Pro (I’m using Premium myself). It’s easy to accidentally use a tool that is not available in Pro and this was a perfect opportunity to check that.

So I headed over to to get started.

Software Development is a Job – Coding is a Passion

I'm Anders Abel, an independent systems architect and developer in Stockholm, Sweden.

profile for Anders Abel at Stack Overflow, Q&A for professional and enthusiast programmers

Code for most posts is available on my GitHub account.

Popular Posts



Powered by WordPress with the Passion for Coding theme.