I am trying to re-organise some Integration Tests we have so that they use a common class for creating a Database and the Data required in the Database to Test against in other classes in the same assembly using [SetUpFixture] NUnit attribute.
I have :
namespace Tests;
public class TestBaseClass : SolutionBaseClass
{
public void Setup()
{
base.CreateDatabase();
base.CreateData();
}
public void Teardown()
{
base.DestroyDatabase();
}
}
[SetUpFixture]
public class Setup : TestBaseClass
{
[SetUp]
public void Setup()
{
base.Setup();
}
[TearDown]
public void Teardown()
{
base.Teardown();
}
}
then individual test fixture classes:
namespace Tests.Services;
[TestFixture]
public class LibraryTest : TestBaseClass
{
[TestFixtureSetUp]
public void SetupTests()
{
// I know am calling the same Setup twice once from SetUpFixture and TestFixture,
// I have handled it so that only one Database/Data gets set up once (for safety mostly!)
base.SetUp();
// Other class initialisations.
}
}
Any ideas what I am doing wrong, I figure it is a problem with the inheritance model being used, as you can tell I am inheriting this from someone else!!
Thanks.
In NUnit 3 one should use OneTimeSetUpAttribute and OneTimeTearDownAttribute on the static methods of the [SetUpFixture] class. Source: http://bartwullems.blogspot.nl/2015/12/upgrading-to-nunit-30-onetimesetup.html
In NUnit 2.0
[SetUpFixture]
class TestHost
{
[SetUp]
public static void AssemblyInitalize()
{
//Global initialization logic here
}
}
In NUnit 3.0
[SetUpFixture]
class TestHost
{
[OneTimeSetUp]
public static void AssemblyInitalize()
{
//Global initialization logic here
}
}
In NUnit 3.0
TestFixtureSetUp
and TestFixtureTearDown
has been renamed to OneTimeSetUp
and OneTimeTearDown
.
Here is the documentation link for above changes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With