After upgrading to NUnit 3.0, which became recently available, some of my tests started to fail.
When I look at the test results, they all failed with the following error message:
SetUpAttribute attribute not allowed in a SetUpFixture
In NUnit 3.0, there are some breaking changes regarding the usage of the SetUpAttribute and the SetUpFixture. You can no longer use the SetUpAttribute and TearDownAttribute inside a SetUpFixture. Instead you have to use the OneTimeSetUpAttribute and OneTimeTearDownAttribute.
In NUnit 2.0, I had the following code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SetUpFixture] | |
class TestHost | |
{ | |
[SetUp] | |
public static void AssemblyInitalize() | |
{ | |
//Global initialization logic here | |
} | |
} |
In NUnit 3.0, this has to change to:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SetUpFixture] | |
class TestHost | |
{ | |
[OneTimeSetUp] | |
public static void AssemblyInitalize() | |
{ | |
//Global initialization logic here | |
} | |
} |
More information can be found here: