/// <summary>
 /// Initializes a new instance of the <see cref="XunitTestAssemblyRunnerContext"/> class.
 /// </summary>
 public XunitTestAssemblyRunnerContext(
     _ITestAssembly testAssembly,
     IReadOnlyCollection <IXunitTestCase> testCases,
     _IMessageSink executionMessageSink,
     _ITestFrameworkExecutionOptions executionOptions) :
     base(testAssembly, testCases, executionMessageSink, executionOptions)
 {
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTestAssemblyRunner"/> class.
 /// </summary>
 /// <param name="testAssembly">The assembly 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="executionMessageSink">The message sink to report run status to.</param>
 /// <param name="executionOptions">The user's requested execution options.</param>
 public XunitTestAssemblyRunner(
     _ITestAssembly testAssembly,
     IEnumerable <IXunitTestCase> testCases,
     _IMessageSink diagnosticMessageSink,
     _IMessageSink executionMessageSink,
     _ITestFrameworkExecutionOptions executionOptions)
     : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
 {
 }
Ejemplo n.º 3
0
 TestableXunitTestAssemblyRunner(
     _ITestAssembly testAssembly,
     IEnumerable <IXunitTestCase> testCases,
     List <_MessageSinkMessage> diagnosticMessages,
     _IMessageSink executionMessageSink,
     _ITestFrameworkExecutionOptions executionOptions)
     : base(testAssembly, testCases, SpyMessageSink.Create(messages: diagnosticMessages), executionMessageSink, executionOptions)
 {
     DiagnosticMessages = diagnosticMessages;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionPerClassTestCollectionFactory" /> class.
        /// </summary>
        /// <param name="testAssembly">The assembly info.</param>
        /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param>
        public CollectionPerClassTestCollectionFactory(
            _ITestAssembly testAssembly,
            _IMessageSink diagnosticMessageSink)
        {
            Guard.ArgumentNotNull(nameof(diagnosticMessageSink), diagnosticMessageSink);

            this.testAssembly = Guard.ArgumentNotNull(nameof(testAssembly), testAssembly);

            collectionDefinitions = TestCollectionFactoryHelper.GetTestCollectionDefinitions(testAssembly.Assembly, diagnosticMessageSink);
        }
 TestableXunitTestAssemblyRunner(
     _ITestAssembly testAssembly,
     IReadOnlyCollection <IXunitTestCase> testCases,
     _IMessageSink executionMessageSink,
     _ITestFrameworkExecutionOptions executionOptions)
 {
     this.testAssembly         = testAssembly;
     this.testCases            = testCases;
     this.executionMessageSink = executionMessageSink;
     this.executionOptions     = executionOptions;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionPerAssemblyTestCollectionFactory" /> class.
        /// </summary>
        /// <param name="testAssembly">The assembly.</param>
        /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param>
        public CollectionPerAssemblyTestCollectionFactory(
            _ITestAssembly testAssembly,
            _IMessageSink diagnosticMessageSink)
        {
            Guard.ArgumentNotNull(nameof(diagnosticMessageSink), diagnosticMessageSink);

            this.testAssembly = Guard.ArgumentNotNull(nameof(testAssembly), testAssembly);

            defaultCollection     = new TestCollection(testAssembly, null, "Test collection for " + Path.GetFileName(testAssembly.Assembly.AssemblyPath));
            collectionDefinitions = TestCollectionFactoryHelper.GetTestCollectionDefinitions(testAssembly.Assembly, diagnosticMessageSink);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestAssemblyRunnerContext{TTestCase}"/> class.
 /// </summary>
 public TestAssemblyRunnerContext(
     _ITestAssembly testAssembly,
     IReadOnlyCollection <TTestCase> testCases,
     _IMessageSink executionMessageSink,
     _ITestFrameworkExecutionOptions executionOptions)
 {
     TestAssembly         = Guard.ArgumentNotNull(testAssembly);
     TestCases            = Guard.ArgumentNotNull(testCases);
     ExecutionMessageSink = Guard.ArgumentNotNull(executionMessageSink);
     ExecutionOptions     = Guard.ArgumentNotNull(executionOptions);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCollection"/> class.
        /// </summary>
        /// <param name="testAssembly">The test assembly the collection belongs to</param>
        /// <param name="collectionDefinition">The optional type which contains the collection definition</param>
        /// <param name="displayName">The display name for the test collection</param>
        /// <param name="uniqueID">The unique ID for the test collection (only used to override default behavior in testing scenarios)</param>
        public TestCollection(
            _ITestAssembly testAssembly,
            _ITypeInfo?collectionDefinition,
            string displayName,
            string?uniqueID = null)
        {
            CollectionDefinition = collectionDefinition;

            this.displayName  = Guard.ArgumentNotNull(displayName);
            this.testAssembly = Guard.ArgumentNotNull(testAssembly);
            this.uniqueID     = uniqueID ?? UniqueIDGenerator.ForTestCollection(testAssembly.UniqueID, this.displayName, CollectionDefinition?.Name);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets an xUnit.net v3 test collection factory, as specified in a reflected <see cref="CollectionBehaviorAttribute"/>.
 /// </summary>
 /// <param name="collectionBehaviorAttribute">The collection behavior attribute.</param>
 /// <param name="testAssembly">The test assembly.</param>
 /// <returns>The collection factory.</returns>
 public static IXunitTestCollectionFactory?GetXunitTestCollectionFactory(
     _IAttributeInfo?collectionBehaviorAttribute,
     _ITestAssembly testAssembly)
 {
     try
     {
         var testCollectionFactoryType = GetTestCollectionFactoryType(collectionBehaviorAttribute);
         return(GetXunitTestCollectionFactory(testCollectionFactoryType, testAssembly));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestAssemblyRunner{TTestCase}"/> class.
        /// </summary>
        /// <param name="testAssembly">The assembly 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="executionMessageSink">The message sink to report run status to.</param>
        /// <param name="executionOptions">The user's requested execution options.</param>
        protected TestAssemblyRunner(
            _ITestAssembly testAssembly,
            IEnumerable <TTestCase> testCases,
            _IMessageSink diagnosticMessageSink,
            _IMessageSink executionMessageSink,
            _ITestFrameworkExecutionOptions executionOptions)
        {
            this.testAssembly          = Guard.ArgumentNotNull(nameof(testAssembly), testAssembly);
            this.testCases             = Guard.ArgumentNotNull(nameof(testCases), testCases);
            this.diagnosticMessageSink = Guard.ArgumentNotNull(nameof(diagnosticMessageSink), diagnosticMessageSink);
            this.executionMessageSink  = Guard.ArgumentNotNull(nameof(executionMessageSink), executionMessageSink);
            this.executionOptions      = Guard.ArgumentNotNull(nameof(executionOptions), executionOptions);

            testCaseOrderer = new DefaultTestCaseOrderer(DiagnosticMessageSink);
        }
Ejemplo n.º 11
0
        TestableTestAssemblyRunner(
            _ITestAssembly testAssembly,
            IEnumerable <_ITestCase> testCases,
            List <_MessageSinkMessage> diagnosticMessages,
            _IMessageSink executionMessageSink,
            _ITestFrameworkExecutionOptions executionOptions,
            RunSummary result,
            bool cancelInRunTestCollectionAsync)
            : base(testAssembly, testCases, SpyMessageSink.Create(messages: diagnosticMessages), executionMessageSink, executionOptions)
        {
            DiagnosticMessages = diagnosticMessages;

            this.result = result;
            this.cancelInRunTestCollectionAsync = cancelInRunTestCollectionAsync;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="configFileName">The test configuration file.</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        public XunitTestFrameworkDiscoverer(
            _IAssemblyInfo assemblyInfo,
            string?configFileName,
            IXunitTestCollectionFactory?collectionFactory = null)
            : base(assemblyInfo)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization      = collectionBehaviorAttribute != null && collectionBehaviorAttribute.GetNamedArgument <bool>("DisableTestParallelization");

            testAssembly          = new TestAssembly(assemblyInfo, configFileName);
            TestCollectionFactory =
                collectionFactory
                ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(collectionBehaviorAttribute, testAssembly)
                ?? new CollectionPerClassTestCollectionFactory(testAssembly);

            TestFrameworkDisplayName = $"{DisplayName} [{TestCollectionFactory.DisplayName}, {(disableParallelization ? "non-parallel" : "parallel")}]";
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Used for de-serialization.
        /// </summary>
        protected TestCollection(
            SerializationInfo info,
            StreamingContext context)
        {
            displayName  = Guard.NotNull("Could not retrieve DisplayName from serialization", info.GetValue <string>("DisplayName"));
            testAssembly = Guard.NotNull("Could not retrieve TestAssembly from serialization", info.GetValue <_ITestAssembly>("TestAssembly"));
            uniqueID     = Guard.NotNull("Could not retrieve UniqueID from serialization", info.GetValue <string>("UniqueID"));

            var assemblyName = info.GetValue <string>("DeclarationAssemblyName");
            var typeName     = info.GetValue <string>("DeclarationTypeName");

            if (!string.IsNullOrWhiteSpace(assemblyName) && !string.IsNullOrWhiteSpace(typeName))
            {
                var type = SerializationHelper.GetType(assemblyName, typeName);
                if (type == null)
                {
                    throw new InvalidOperationException($"Failed to deserialize type '{typeName}' in assembly '{assemblyName}'");
                }

                CollectionDefinition = Reflector.Wrap(type);
            }
        }
Ejemplo n.º 14
0
 public static TestCollection TestCollection(
     _ITestAssembly assembly,
     _ITypeInfo?collectionDefinition = null,
     string?displayName = null) =>
 new TestCollection(assembly, collectionDefinition, displayName ?? $"[Unit Test] Collection for '{assembly.Assembly.Name}'");
Ejemplo n.º 15
0
 public CustomTestCollectionFactory(_ITestAssembly testAssembly)
 {
 }
Ejemplo n.º 16
0
 public MyTestCollectionFactory(_ITestAssembly assembly)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Gets an xUnit.net v3 test collection factory.
 /// </summary>
 /// <param name="testCollectionFactoryType">The test collection factory type</param>
 /// <param name="testAssembly">The test assembly under test</param>
 public static IXunitTestCollectionFactory?GetXunitTestCollectionFactory(
     Type testCollectionFactoryType,
     _ITestAssembly testAssembly) =>
 Get <IXunitTestCollectionFactory>(testCollectionFactoryType, new object[] { testAssembly });