/// <summary> /// Initializes a new instance of the <see cref="TestClass"/> class. /// </summary> /// <param name="testCollection">The test collection the class belongs to</param> /// <param name="class">The test class</param> /// <param name="uniqueID">The unique ID for the test class (only used to override default behavior in testing scenarios)</param> public TestClass( _ITestCollection testCollection, _ITypeInfo @class, string?uniqueID = null) { this.@class = Guard.ArgumentNotNull(@class); this.testCollection = Guard.ArgumentNotNull(testCollection); this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestClass(TestCollection.UniqueID, Class.Name); }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestCollectionRunnerContext"/> class. /// </summary> public XunitTestCollectionRunnerContext( _ITestCollection testCollection, IReadOnlyCollection <IXunitTestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IReadOnlyDictionary <Type, object> assemblyFixtureMappings) : base(testCollection, testCases, messageBus, testCaseOrderer, aggregator, cancellationTokenSource) { AssemblyFixtureMappings = assemblyFixtureMappings; }
TestableXunitTestCollectionRunner( _ITestCollection testCollection, IEnumerable <IXunitTestCase> testCases, List <_MessageSinkMessage> diagnosticMessages, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) : base(testCollection, testCases, SpyMessageSink.Create(messages: diagnosticMessages), messageBus, testCaseOrderer, aggregator, cancellationTokenSource) { DiagnosticMessages = diagnosticMessages; }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestCollectionRunner"/> class. /// </summary> /// <param name="testCollection">The test collection that contains the tests to be run.</param> /// <param name="testCases">The test cases to be run.</param> /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param> /// <param name="messageBus">The message bus to report run status to.</param> /// <param name="testCaseOrderer">The test case orderer that will be used to decide how to order the test.</param> /// <param name="aggregator">The exception aggregator used to run code and collect exceptions.</param> /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param> public XunitTestCollectionRunner( _ITestCollection testCollection, IEnumerable <IXunitTestCase> testCases, _IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) : base(testCollection, testCases, messageBus, testCaseOrderer, aggregator, cancellationTokenSource) { DiagnosticMessageSink = Guard.ArgumentNotNull(nameof(diagnosticMessageSink), diagnosticMessageSink); }
/// <summary> /// Initializes a new instance of the <see cref="TestCollectionRunnerContext{TTestCase}"/> class. /// </summary> public TestCollectionRunnerContext( _ITestCollection testCollection, IReadOnlyCollection<TTestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) : base(messageBus, aggregator, cancellationTokenSource) { TestCollection = Guard.ArgumentNotNull(testCollection); TestCases = Guard.ArgumentNotNull(testCases); this.testCaseOrderer = Guard.ArgumentNotNull(testCaseOrderer); }
protected override Task <RunSummary> RunTestCollectionAsync( IMessageBus messageBus, _ITestCollection testCollection, IEnumerable <IXunitTestCase> testCases, CancellationTokenSource cancellationTokenSource) { foreach (var testCase in testCases) { TestCasesRun.Add(Tuple.Create(Thread.CurrentThread.ManagedThreadId, testCase)); } Thread.Sleep(5); // Hold onto the worker thread long enough to ensure tests all get spread around return(Task.FromResult(new RunSummary())); }
/// <summary> /// Initializes a new instance of the <see cref="TestCollectionRunner{TTestCase}"/> class. /// </summary> /// <param name="testCollection">The test collection that contains the tests to be run.</param> /// <param name="testCases">The test cases to be run.</param> /// <param name="messageBus">The message bus to report run status to.</param> /// <param name="testCaseOrderer">The test case orderer that will be used to decide how to order the test.</param> /// <param name="aggregator">The exception aggregator used to run code and collect exceptions.</param> /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param> protected TestCollectionRunner( _ITestCollection testCollection, IEnumerable <TTestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { this.testCollection = Guard.ArgumentNotNull(nameof(testCollection), testCollection); this.testCases = Guard.ArgumentNotNull(nameof(testCases), testCases); this.messageBus = Guard.ArgumentNotNull(nameof(messageBus), messageBus); this.testCaseOrderer = Guard.ArgumentNotNull(nameof(testCaseOrderer), testCaseOrderer); this.cancellationTokenSource = Guard.ArgumentNotNull(nameof(cancellationTokenSource), cancellationTokenSource); this.aggregator = Guard.ArgumentNotNull(nameof(aggregator), aggregator); }
protected override Task <RunSummary> RunTestCollectionAsync( IMessageBus messageBus, _ITestCollection testCollection, IEnumerable <_ITestCase> testCases, CancellationTokenSource cancellationTokenSource) { if (cancelInRunTestCollectionAsync) { cancellationTokenSource.Cancel(); } RunTestCollectionAsync_AggregatorResult = Aggregator.ToException(); CollectionsRun.Add(Tuple.Create(testCollection, testCases)); return(Task.FromResult(result)); }
TestableTestCollectionRunner( _ITestCollection testCollection, IEnumerable <_ITestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, RunSummary result, bool cancelInRunTestClassAsync) : base(testCollection, testCases, messageBus, testCaseOrderer, aggregator, cancellationTokenSource) { TokenSource = cancellationTokenSource; this.result = result; this.cancelInRunTestClassAsync = cancelInRunTestClassAsync; }
TestableXunitTestCollectionRunner( _ITestCollection testCollection, IReadOnlyCollection <IXunitTestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IReadOnlyDictionary <Type, object> assemblyFixtureMappings) { this.testCollection = testCollection; this.testCases = testCases; this.messageBus = messageBus; this.testCaseOrderer = testCaseOrderer; this.aggregator = aggregator; this.cancellationTokenSource = cancellationTokenSource; this.assemblyFixtureMappings = assemblyFixtureMappings; }
TestableTestCollectionRunner( _ITestCollection testCollection, IReadOnlyCollection <_ITestCase> testCases, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, RunSummary result, bool cancelInRunTestClassAsync) { TestCollection = testCollection; this.testCases = testCases; this.messageBus = messageBus; this.testCaseOrderer = testCaseOrderer; this.aggregator = aggregator; TokenSource = cancellationTokenSource; this.result = result; this.cancelInRunTestClassAsync = cancelInRunTestClassAsync; }
/// <summary> /// Used for de-serialization. /// </summary> protected TestClass( SerializationInfo info, StreamingContext context) { testCollection = Guard.NotNull("Could not retrieve TestCollection from serialization", info.GetValue <_ITestCollection>("TestCollection")); uniqueID = Guard.NotNull("Could not retrieve UniqueID from serialization", info.GetValue <string>("UniqueID")); var assemblyName = Guard.NotNull("Could not retrieve ClassAssemblyName from serialization", info.GetValue <string>("ClassAssemblyName")); var typeName = Guard.NotNull("Could not retrieve ClassTypeName from serialization", info.GetValue <string>("ClassTypeName")); var type = SerializationHelper.GetType(assemblyName, typeName); if (type == null) { throw new InvalidOperationException($"Failed to deserialize type '{typeName}' in assembly '{assemblyName}'"); } @class = Reflector.Wrap(type); }