/// <inheritdoc/>
        public override void Deserialize(IXunitSerializationInfo data)
        {
            _skipReason         = data.GetValue <string>("SkipReason");
            _scenarioIdentifier = data.GetValue <IScenarioIdentifier>(nameof(ScenarioIdentifier));

            base.Deserialize(data);
        }
Exemplo n.º 2
0
 public ExecutionErrorScenarioTestCase(IMessageSink diagnosticMessageSink,
                                       TestMethodDisplay methodDisplayOrDefault, TestMethodDisplayOptions methodDisplayOptionsOrDefault,
                                       ITestMethod testMethod, IScenarioIdentifier scenarioIdentifier, string errorMessage)
     : base(diagnosticMessageSink, methodDisplayOrDefault, methodDisplayOptionsOrDefault, testMethod,
            errorMessage)
 {
     _scenarioIdentifier = scenarioIdentifier ?? throw new ArgumentNullException(nameof(scenarioIdentifier));
 }
 public ScenarioTestCase(IMessageSink diagnosticMessageSink,
                         TestMethodDisplay defaultMethodDisplay,
                         TestMethodDisplayOptions defaultMethodDisplayOptions,
                         ITestMethod testMethod,
                         IScenarioIdentifier scenarioIdentifier,
                         string skipReason = null) : base(diagnosticMessageSink, defaultMethodDisplay,
                                                          defaultMethodDisplayOptions, testMethod,
                                                          null)
 {
     _scenarioIdentifier = scenarioIdentifier ?? throw new ArgumentNullException(nameof(scenarioIdentifier));
     _skipReason         = skipReason;
 }
Exemplo n.º 4
0
        public IScenario GetScenario(IScenarioIdentifier identifier)
        {
            var rosbagIdentifier = identifier as RosbagScenarioIdentifier;

            if (rosbagIdentifier == null)
            {
                throw new ArgumentException("Identifier is no RosbagIdentifier");
            }

            var scenario = _scenarios.GetOrAdd(rosbagIdentifier.Bagfile, (x) => new RosbagScenario(x));

            return(scenario);
        }
Exemplo n.º 5
0
        public IScenario GetScenario(IScenarioIdentifier scenarioIdentifier)
        {
            var si = (TestScenarioIdentifier)scenarioIdentifier;

            switch (si.DiscoveryBehavior)
            {
            case TestScenarioDiscoveryBehavior.Null:
                return(null);

            case TestScenarioDiscoveryBehavior.Exception:
                throw new InvalidOperationException("Scenario discovery throws exception");

            case TestScenarioDiscoveryBehavior.Default:
            default:
                return(new TestScenario());
            }
            ;
        }
        protected override async Task AfterTestCaseStartingAsync()
        {
            await base.AfterTestCaseStartingAsync();

            try
            {
                var scenarioAttributes = TestCase.TestMethod.GetScenarioAttributes(DiagnosticMessageSink);

                if (!scenarioAttributes.Any())
                {
                    throw new InvalidOperationException(
                              $"No scenario specified for {TestCase.TestMethod.TestClass.Class.Name}.{TestCase.TestMethod.Method.Name}. Make sure to add at least one ScenarioAttribute to the test method or class.");
                }

                foreach (var scenarioAttribute in scenarioAttributes)
                {
                    IScenarioIdentifier scenarioIdentifier = null;
                    var testRunnerAggregator = new ExceptionAggregator(Aggregator);
                    var skipReason           = scenarioAttribute.GetNamedArgument <string>("Skip");

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

                    var test       = CreateTest(TestCase, scenarioIdentifier);
                    var testRunner = new ScenarioTestRunner(test, DiagnosticMessageSink, MessageBus, TestClass, ConstructorArguments, TestMethod,
                                                            TestMethodArguments, skipReason, BeforeAfterAttributes, testRunnerAggregator,
                                                            CancellationTokenSource);

                    _testRunners.Add(testRunner);
                }
            }
            catch (Exception ex)
            {
                ScenarioDiscoveryException = ex;
            }
        }
        protected virtual ScenarioTest CreateTest(IXunitTestCase testCase, IScenarioIdentifier scenarioIdentifier)
        {
            var displayName = $"{testCase.DisplayName} (Scenario: {scenarioIdentifier})";

            return(new ScenarioTest((MultipleScenariosTestCase)testCase, scenarioIdentifier, displayName));
        }
 public ScenarioTest(MultipleScenariosTestCase testCase, IScenarioIdentifier scenarioIdentifier, string displayName)
     : base(testCase, displayName)
 {
     ScenarioIdentifier = scenarioIdentifier;
 }
 public ScenarioTest(ScenarioTestCase testCase, string displayName)
     : base(testCase, displayName)
 {
     ScenarioIdentifier = testCase.ScenarioIdentifier;
 }
Exemplo n.º 10
0
 public static IScenarioDiscoverer GetDiscoverer(IMessageSink diagnosticsMessageSink,
                                                 IScenarioIdentifier scenarioIdentifier)
 {
     return(GetDiscoverer(diagnosticsMessageSink, scenarioIdentifier.ScenarioDiscovererType));
 }
Exemplo n.º 11
0
 public IScenario GetScenario(IScenarioIdentifier scenarioIdentifier)
 {
     return(null);
 }