Ejemplo n.º 1
0
    public static void BeforeAfterTestAttributesComeFromBothTestClassAndTestMethod()
    {
        var testCase    = Mocks.XunitTestCase <ClassUnderTest>("Passing");
        var messageBus  = Substitute.For <IMessageBus>();
        var aggregator  = new ExceptionAggregator();
        var tokenSource = new CancellationTokenSource();

        var runner = new XunitTestCaseRunner(testCase, "Display Name", "Skip Reason", new object[0], new object[0], messageBus, aggregator, tokenSource);

        Assert.Collection(runner.BeforeAfterAttributes,
                          attr => Assert.IsType <BeforeAfterOnClass>(attr),
                          attr => Assert.IsType <BeforeAfterOnMethod>(attr)
                          );
    }
Ejemplo n.º 2
0
    public static void BeforeAfterTestAttributesComeFromBothTestClassAndTestMethod()
    {
        var testCase = Mocks.XunitTestCase<ClassUnderTest>("Passing");
        var messageBus = Substitute.For<IMessageBus>();
        var aggregator = new ExceptionAggregator();
        var tokenSource = new CancellationTokenSource();

        var runner = new XunitTestCaseRunner(testCase, "Display Name", "Skip Reason", new object[0], new object[0], messageBus, aggregator, tokenSource);

        Assert.Collection(runner.BeforeAfterAttributes,
            attr => Assert.IsType<BeforeAfterOnClass>(attr),
            attr => Assert.IsType<BeforeAfterOnMethod>(attr)
        );
    }
        protected override async Task <RunSummary> RunTestCaseAsync(IXunitTestCase originalTestCase)
        {
            var messageBusInterceptor = new SkippableTestMessageBus(MessageBus, __skippingExceptionNames);

            var isTheory = originalTestCase is XunitTheoryTestCase;
            XunitTestCaseRunner testRunner = isTheory ?
                                             new TimeoutEnforcingXunitTheoryTestCaseRunner(originalTestCase, originalTestCase.DisplayName, originalTestCase.SkipReason, _constructorArguments, _diagnosticMessageSink, messageBusInterceptor, new ExceptionAggregator(Aggregator), CancellationTokenSource) :
                                             new TimeoutEnforcingXunitTestCaseRunner(originalTestCase, originalTestCase.DisplayName, originalTestCase.SkipReason, _constructorArguments, originalTestCase.TestMethodArguments, messageBusInterceptor, new ExceptionAggregator(Aggregator), CancellationTokenSource);

            var result = await testRunner.RunAsync();

            result.Failed  -= messageBusInterceptor.SkippedCount;
            result.Skipped += messageBusInterceptor.SkippedCount;

            return(result);
        }
Ejemplo n.º 4
0
    public static void BeforeAfterTestAttributesComeFromTestCollectionAndTestClassAndTestMethod()
    {
        var collection  = Mocks.TestCollection(definition: Reflector.Wrap(typeof(BeforeAfterCollection)));
        var testCase    = TestData.XunitTestCase <ClassUnderTest>("Passing", collection);
        var messageBus  = Substitute.For <IMessageBus>();
        var aggregator  = new ExceptionAggregator();
        var tokenSource = new CancellationTokenSource();

        var runner = new XunitTestCaseRunner(testCase, "Display Name", "Skip Reason", new object[0], new object[0], messageBus, aggregator, tokenSource);

        Assert.Collection(
            runner.BeforeAfterAttributes.OrderBy(a => a.GetType().Name),
            attr => Assert.IsType <BeforeAfterOnAssembly>(attr),
            attr => Assert.IsType <BeforeAfterOnClass>(attr),
            attr => Assert.IsType <BeforeAfterOnCollection>(attr),
            attr => Assert.IsType <BeforeAfterOnMethod>(attr)
            );
    }
 public Task<RunSummary> RunAsync(
     IMessageSink diagnosticMessageSink,
     IMessageBus messageBus,
     object[] constructorArguments,
     ExceptionAggregator aggregator,
     CancellationTokenSource cancellationTokenSource)
 {
     XunitTestCaseRunner runner;
     if (_wrappedTestCase is XunitTheoryTestCase)
     {
         runner = new XunitTheoryTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource);
     }
     else
     {
         runner = new XunitTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource);
     }
     return runner.RunAsync();
 }
Ejemplo n.º 6
0
        public Task <RunSummary> RunAsync(
            IMessageSink diagnosticMessageSink,
            IMessageBus messageBus,
            object[] constructorArguments,
            ExceptionAggregator aggregator,
            CancellationTokenSource cancellationTokenSource)
        {
            XunitTestCaseRunner runner;

            if (_wrappedTestCase is XunitTheoryTestCase)
            {
                runner = new XunitTheoryTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource);
            }
            else
            {
                runner = new XunitTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource);
            }
            return(runner.RunAsync());
        }
Ejemplo n.º 7
0
		public VsixRunSummary Run (VsixTestCase testCase, IMessageBus messageBus, object[] constructorArguments)
		{
			var aggregator = new ExceptionAggregator ();

			var result = new XunitTestCaseRunner (
					testCase, testCase.DisplayName, testCase.SkipReason, constructorArguments, testCase.TestMethodArguments, messageBus,
					aggregator, new CancellationTokenSource ())
				.RunAsync ()
				.Result
				.ToVsixRunSummary ();

			if (aggregator.HasExceptions)
				result.Exception = aggregator.ToException ();

			return result;
		}