Last week after introducing localization into our application our builds started to fail. Inside the build log we saw that only tests related to localization were failing.
What happened? The problem was that the tests where expecting a specific culture to be set which was different on our local machines compared to the build server. So we needed a way to set the (UI)culture for our tests.
A solution that worked for us was to set the CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture in the Assembly initializer of our tests:
Remark: Don’t forget to add the [TestClass] attribute on top of your class otherwise MSTest will not invoke the AssemblyInitialize method.