/// <inheritdoc cref="IXunitTestCaseDiscoverer"/>
        public IEnumerable <IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod,
                                                     IAttributeInfo expectThatAttribute)
        {
            // Check if expectation should be skipped
            if (expectThatAttribute.GetNamedArgument <string>(nameof(ExpectThatAttribute.Skip)) != null)
            {
                return(CreateSkipTestCases(discoveryOptions, testMethod));
            }

            try
            {
                var scenarioAttributes = testMethod.GetScenarioAttributes(DiagnosticMessageSink);

                if (!scenarioAttributes.Any())
                {
                    return(CreateNoScenarioTestCases(discoveryOptions, testMethod));
                }

                if (IsPreEnumerationSupported(discoveryOptions))
                {
                    return(CreatePreEnumeratedTestCases(discoveryOptions, testMethod, scenarioAttributes));
                }
                else
                {
                    return(CreateSingleTestCaseForAllScenarios(discoveryOptions, testMethod));
                }
            }
            catch (Exception e)
            {
                DiagnosticMessageSink.OnMessage(new PrintableDiagnosticMessage($"Exception thrown during scenario expectation discovery on '{testMethod.TestClass.Class.Name}.{testMethod.Method.Name}'.{Environment.NewLine}{e}"));
                throw;
            }
        }
Ejemplo n.º 2
0
        public static IScenarioIdentifier CreateScenarioIdentifier(ITestMethod testMethod)
        {
            var discoverer            = new TestScenarioDiscoverer();
            var testScenarioAttribute = testMethod
                                        .GetScenarioAttributes()
                                        .Single();

            return(discoverer.GetScenarioIdentifier(testScenarioAttribute));
        }