Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test run aborted when there are duplicate trait attributes #358

Closed
jeremymeng opened this issue Jan 19, 2017 · 1 comment
Closed

Test run aborted when there are duplicate trait attributes #358

jeremymeng opened this issue Jan 19, 2017 · 1 comment

Comments

@jeremymeng
Copy link
Member

Description

No helpful information to users when tests have duplicate trait attributes

Steps to reproduce

  1. dotnet new -t xunittest
  2. 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);
        }
    }
}
  1. dotnet restore
  2. 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.
@codito
Copy link
Contributor

codito commented Jan 23, 2017

@jeremymeng thanks for reporting this issue. It is fixed with #328. We will take the fix as part of next insertion to dotnet-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants