Closed
Description
Description
No helpful information to users when tests have duplicate trait attributes
Steps to reproduce
- dotnet new -t xunittest
- change the content of Tests.cs to the following
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Tests
{
[Category(TestCategory.Async)]
public class Tests
{
[Fact]
[Category(TestCategory.Async)]
public void Test1()
{
Assert.True(true);
}
}
public enum TestCategory
{
Unspecified = 0,
Async,
}
[TraitDiscoverer("Tests.CategoryDiscoverer", "xunittest")]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
public class CategoryAttribute : Attribute, ITraitAttribute
{
public CategoryAttribute(TestCategory category)
{
}
}
public class CategoryDiscoverer : ITraitDiscoverer
{
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
{
var args = traitAttribute.GetConstructorArguments().ToList();
yield return new KeyValuePair<string, string>(args[0].ToString(), string.Empty);
}
}
}
- dotnet restore
- dotnet test
Expected behavior
Warning about duplicate attributes, but test should run
Actual behavior
Starting test execution, please wait...
Error: The active Test Run was aborted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels