Skip to content

Instantly share code, notes, and snippets.

@deejaygraham
Last active August 29, 2015 14:00
Show Gist options
  • Save deejaygraham/11375398 to your computer and use it in GitHub Desktop.
Save deejaygraham/11375398 to your computer and use it in GitHub Desktop.
xUnit test categorisation using traits
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class InMemoryTestAttribute : TraitAttribute
{
public InMemoryTestAttribute()
: base("Category", "Fast")
{
}
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TouchingFileSystemTestAttribute : TraitAttribute
{
public TouchingFileSystemTestAttribute()
: base("Category", "Slow - FileSystem")
{
}
}
public class CompilerFacts
{
[Fact]
[InMemoryTest]
public void Compiler_Created_With_Default_Properties()
{
// ... fast test here
}
[Fact]
[TouchingFileSystemTest]
public void Compiler_Writes_File_In_Correct_Location()
{
// ... slow test here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment