예제 #1
0
 public ScenarioTestCaseRunner(ScenarioTestCase scenarioTestCase, string displayName, string skipReason,
                               object[] constructorArguments, IMessageSink diagnosticMessageSink, IMessageBus messageBus,
                               ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(scenarioTestCase, displayName, skipReason, constructorArguments, new object[0], messageBus,
            aggregator, cancellationTokenSource)
 {
     DiagnosticMessageSink = diagnosticMessageSink;
 }
        private ICollection <IXunitTestCase> CreatePreEnumeratedTestCases(
            ITestFrameworkDiscoveryOptions discoveryOptions,
            ITestMethod testMethod, IEnumerable <IAttributeInfo> scenarioAttributes)
        {
            var testCases = new List <IXunitTestCase>();

            foreach (var scenarioAttribute in scenarioAttributes)
            {
                IScenarioIdentifier scenarioIdentifier;
                var skipReason = scenarioAttribute.GetNamedArgument <string>(nameof(ScenarioAttribute.Skip));

                try
                {
                    var scenarioDiscoverer =
                        ScenarioDiscovererFactory.GetDiscoverer(DiagnosticMessageSink, scenarioAttribute);
                    scenarioIdentifier = scenarioDiscoverer.GetScenarioIdentifier(scenarioAttribute);
                }
                catch (Exception e)
                {
                    scenarioIdentifier = new DummyScenarioDiscoverer().GetScenarioIdentifier(scenarioAttribute);

                    if (skipReason == null)
                    {
                        testCases.Add(
                            new ExecutionErrorScenarioTestCase(
                                DiagnosticMessageSink,
                                discoveryOptions.MethodDisplayOrDefault(),
                                discoveryOptions.MethodDisplayOptionsOrDefault(),
                                testMethod,
                                scenarioIdentifier,
                                $"{e.Message} for {testMethod.TestClass.Class.Name}.{testMethod.Method.Name}, Scenario {scenarioIdentifier}."
                                )
                            );

                        continue;
                    }
                }

                var testCase = new ScenarioTestCase(DiagnosticMessageSink,
                                                    discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(),
                                                    testMethod, scenarioIdentifier, skipReason);

                testCases.Add(testCase);
            }

            return(testCases);
        }
 public ScenarioTest(ScenarioTestCase testCase, string displayName)
     : base(testCase, displayName)
 {
     ScenarioIdentifier = testCase.ScenarioIdentifier;
 }