Example #1
0
        static void DiscoverAllTraits(this ITestCase testCase)
        {
            if (testCase.Traits == null)
            {
                return;
            }

            // the following code is a work around an issue in the extensions that
            // was fixed in https://github.com/dotnet/arcade/pull/5425 but until we get the
            // arcade update, we do the following, check for the discoverer and then add
            // the expected category for the ActiveIssue
            var nullMessageSink = new NullMessageSink();
            var traitAttributes = testCase.TestMethod?.Method?.GetCustomAttributes(typeof(ITraitAttribute));

            if (traitAttributes == null)
            {
                return;
            }
            foreach (var traitAttribute in traitAttributes)
            {
                var discovererAttribute = traitAttribute.GetCustomAttributes(typeof(TraitDiscovererAttribute)).FirstOrDefault();
                if (discovererAttribute == null)
                {
                    continue;
                }

                var discoverer = ExtensibilityPointFactory.GetTraitDiscoverer(nullMessageSink, discovererAttribute);

                if (discoverer == null || !(discoverer is ActiveIssueDiscoverer))
                {
                    continue;
                }

                // add the missing trait
                if (testCase.Traits.ContainsKey(XunitConstants.Category))
                {
                    if (!testCase.Traits[XunitConstants.Category].Contains("failing"))
                    {
                        testCase.Traits[XunitConstants.Category].Add("failing");
                    }
                }
                else
                {
                    testCase.Traits.Add(XunitConstants.Category, new List <string> {
                        "failing"
                    });
                }
            }
        }
 protected BenchmarkTestCaseBase()
 {
     // No way for us to get access to the message sink on the execution de-serialization path.
     // Fortunately, have reported errors during discovery.
     DiagnosticMessageSink = new NullMessageSink();
 }