Thursday, December 24, 2015

Upgrading to NUnit 3.0 - OneTimeSetUp: SetUpAttribute attribute not allowed in a SetUpFixture

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:

In NUnit 3.0, this has to change to:

More information can be found here:

3 comments:

Anthony Steele said...

Hi

Your nunit doc links are broken.

Thanks for the post, it's the only thing that I can find on the the subject of this error.

Murray said...

Thank-you, your google-juice helped me upgrade a legacy solution quickly. :-)

Unknown said...

Thanks. This helped me get the tests running again.