Skip to content

Instantly share code, notes, and snippets.

@geirsagberg
Last active April 24, 2018 13:33
Show Gist options
  • Save geirsagberg/2585edb49b518d0bf5343a7c357e0642 to your computer and use it in GitHub Desktop.
Save geirsagberg/2585edb49b518d0bf5343a7c357e0642 to your computer and use it in GitHub Desktop.
xUnit integration test trait attribute
using System.Collections.Generic;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace MyProject.TestUtils
{
public class IntegrationTestDiscoverer : ITraitDiscoverer
{
internal const string DiscovererTypeName = nameof(MyProject) + "." + nameof(TestUtils) + "." + nameof(IntegrationTestDiscoverer);
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
{
yield return new KeyValuePair<string, string>("Category", "IntegrationTest");
}
}
[TraitDiscoverer(IntegrationTestDiscoverer.DiscovererTypeName, nameof(MyProject) + "." + nameof(TestUtils))]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class IntegrationTestAttribute : Attribute, ITraitAttribute
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment