سؤال

I'm setting up builds on a new Bamboo instance (5.1.0.3901) running on Windows Server 2008.

The NUnit test runner is started via MSBuild to run tests. Some of my tests that work fine on my machine and another server fail now. Apparently all those tests depend on culture settings. As far as I can see all of them either parse date strings via DateTime.Parse(string) or compare language-dependent error messages to hard-coded expected messages in German.

I have logged Thread.CurrentThread.CurrentUICulture ("en-US") and Thread.CurrentThread.CurrentCulture ("de-DE").

The OS Locale ist set to "de-DE".

How can I make these tests pass without changing them? Because they are so many, I would much prefer to configure that NUnit (or MSBuild or Bamboo) runs everything with "de-DE".

هل كانت مفيدة؟

المحلول

NUnit has the SetUpFixture attribute that

marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace. The class may contain at most one method marked with the SetUpAttribute and one method marked with the TearDownAttribute.

I think it is the most global setup chance you have for setting Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture before running your tests. This might be a short-term thing that could help you.

But since it seems that you have a lot of unit tests in place it should not really bother you to make the DateTime.Parse changes in your code base...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top