Skip to content

Instantly share code, notes, and snippets.

@Kritner
Created September 1, 2018 19:04
Show Gist options
  • Select an option

  • Save Kritner/ac918a184e771978de8666567e98e124 to your computer and use it in GitHub Desktop.

Select an option

Save Kritner/ac918a184e771978de8666567e98e124 to your computer and use it in GitHub Desktop.
"Strongly typed" NUnit categories
// Haven't figured out how to apply to assembly correctly, but added it as a flag in my base anyway
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public class BaseCategoryAttribute : CategoryAttribute { }
public class FastIntegrationTestAttribute : BaseCategoryAttribute { }
public class LongRunningIntegrationTestAttribute : BaseCategoryAttribute { }
public class UnitTestAttribute : BaseCategoryAttribute { }
public class CoreTestAttribute : BaseCategoryAttribute { }
[TestFixture, UnitTest, CoreTest]
public class SomeClassTests
{
// This test has categories TestFixture, UnitTest, CoreTest
[Test, CoreTest]
public void ShouldDoSomething()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment