ProblemGiven a generic NUnit test fixture:
Code:
[TestFixture(typeof(SqlLiteInMemoryFixture))]
[TestFixture(typeof(SqlServerFixture))]
internal class CountryModelOperationsTest<T> : ExampleWebApiTest<T>
where T : DbFixture<ExampleWebApiDbContext>, new()
{
// tests...
}
I want NCrunch to treat only SqlServerFixture as an exclusive resource.
Today this requires creating a separate wrapper class:
Code:
[ExclusivelyUses("SqlServer")]
internal class CountryModelOperationsTest_SqlServer
: CountryModelOperationsTest<SqlServerFixture>
{ }
This becomes tedious as the number of test classes grows, since the wrapper exists only to apply the NCrunch attribute.
Suggested enhancementAllow NCrunch to detect exclusive resource usage via an interface implemented by any attribute.
This would let me declare exclusive resources without inheriting from NCrunch-specific attributes or creating wrapper test classes.
Example:
Code:
public interface IExclusivelyUses
{
string ResourceName { get; }
}
public class SqlServerFixtureAttribute : TestFixtureAttribute, IExclusivelyUses
{
public string ResourceName => "SqlServer";
public SqlServerFixtureAttribute()
: base(typeof(SqlServerFixture))
{
}
}
[SqlLiteInMemoryFixture]
[SqlServerFixture]
internal class CountryModelOperationsTest<T> : ExampleWebApiTest<T>
where T : DbFixture<ExampleWebApiDbContext>, new()
{
// tests...
}
If NCrunch recognized interfaces like IExclusivelyUses on attributes applied to fixtures or test classes,
it could treat the corresponding tests as exclusive without requiring derived test classes.