The NUnit documentation doesn\'t tell me when to use a method with a TestFixtureSetup
and when to do the setup in the constructor.
public class MyTe
One thing you can't do with [TestFixtureSetup]
that you can do in the constructor is receive parameters from the [TestFixture]
.
If you want to parameterise your test fixture, then you will have to use the constructor for at least some of the set-up. So far, I've only used this for integration tests, e.g. for testing a data access layer with multiple data providers:
[TestFixture("System.Data.SqlClient",
"Server=(local)\\SQLEXPRESS;Initial Catalog=MyTestDatabase;Integrated Security=True;Pooling=False"))]
[TestFixture("System.Data.SQLite", "Data Source=MyTestDatabase.s3db")])]
internal class MyDataAccessLayerIntegrationTests
{
MyDataAccessLayerIntegrationTests(
string dataProvider,
string connectionString)
{
...
}
}