public XunitTestFrameworkExecutorWithAssemblyFixture(
     AssemblyName assemblyName,
     ISourceInformationProvider sourceInformationProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider = null)
        {
            Guard.ArgumentNotNull("assemblyInfo", assemblyInfo);

            this.assemblyInfo = assemblyInfo;
            this.sourceProvider = sourceProvider ?? new VisualStudioSourceInformationProvider();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="T:Xunit.VisualStudioSourceInformationProvider"/>).</param>
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public XunitFrontController(string assemblyFileName,
                                    string configFileName = null,
                                    bool shadowCopy = true,
                                    string shadowCopyFolder = null,
                                    ISourceInformationProvider sourceInformationProvider = null,
                                    IMessageSink diagnosticMessageSink = null)
        {
            this.assemblyFileName = assemblyFileName;
            this.configFileName = configFileName;
            this.shadowCopy = shadowCopy;
            this.shadowCopyFolder = shadowCopyFolder;
            this.sourceInformationProvider = sourceInformationProvider;
            this.diagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
#if !XAMARIN && !WINDOWS_PHONE_APP && !WINDOWS_PHONE && !ASPNET50 && !ASPNETCORE50
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
#else
                this.sourceInformationProvider = new NullSourceInformationProvider();
#endif
                toDispose.Push(this.sourceInformationProvider);
            }

        }
Ejemplo n.º 4
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
#if !ANDROID
            Guard.ArgumentValid("xunitExecutionAssemblyPath", "File not found: " + xunitExecutionAssemblyPath, File.Exists(xunitExecutionAssemblyPath));
#endif
            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

#if !ANDROID
            var name = AssemblyName.GetAssemblyName(xunitExecutionAssemblyPath);
            var testFrameworkAssemblyName = name.FullName;
#else
            var name = Assembly.Load(xunitExecutionAssemblyPath);
            var testFrameworkAssemblyName = name.FullName;
#endif

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = appDomain.CreateObject<IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            framework = appDomain.CreateObject<ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
Ejemplo n.º 5
0
 // Used by Xunit2 when initializing for both discovery and execution.
 internal Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                           string assemblyFileName,
                           string configFileName,
                           bool shadowCopy,
                           string shadowCopyFolder = null,
                           IMessageSink diagnosticMessageSink = null)
     : this(sourceInformationProvider, null, assemblyFileName, GetXunitExecutionAssemblyPath(assemblyFileName), configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink) { }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Xunit.Sdk.XunitTestFrameworkExecutor"/> class.
 /// </summary>
 /// <param name="assemblyName">Name of the test assembly.</param><param name="sourceInformationProvider">The source line number information provider.</param><param name="diagnosticMessageSink">The message sink to report diagnostic messages to.</param>
 public BrowserTestFrameworkExecutor(
     AssemblyName assemblyName,
     ISourceInformationProvider sourceInformationProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
 }
Ejemplo n.º 7
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder,
                         IMessageSink diagnosticMessageSink)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
            {
                assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);
            }

            framework  = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="appDomainSupport">Determines whether tests should be run in a separate app domain.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="T:Xunit.VisualStudioSourceInformationProvider"/>).</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public XunitFrontController(AppDomainSupport appDomainSupport,
                                    string assemblyFileName,
                                    string configFileName = null,
                                    bool shadowCopy = true,
                                    string shadowCopyFolder = null,
                                    ISourceInformationProvider sourceInformationProvider = null,
                                    IMessageSink diagnosticMessageSink = null)
        {
            this.appDomainSupport = appDomainSupport;
            this.assemblyFileName = assemblyFileName;
            this.configFileName = configFileName;
            this.shadowCopy = shadowCopy;
            this.shadowCopyFolder = shadowCopyFolder;
            this.sourceInformationProvider = sourceInformationProvider;
            this.diagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
#if NETSTANDARD1_1
                this.sourceInformationProvider = new NullSourceInformationProvider();
#else
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
#endif
                toDispose.Push(this.sourceInformationProvider);
            }

        }
Ejemplo n.º 9
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder,
                         IMessageSink diagnosticMessageSink)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = appDomain.CreateObject<IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            framework = appDomain.CreateObject<ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
Ejemplo n.º 10
0
 public static TestableXunitTestFrameworkDiscoverer Create(IAssemblyInfo assembly = null,
                                                           ISourceInformationProvider sourceProvider     = null,
                                                           IMessageSink diagnosticMessageSink            = null,
                                                           IXunitTestCollectionFactory collectionFactory = null)
 {
     return(new TestableXunitTestFrameworkDiscoverer(assembly ?? Mocks.AssemblyInfo(), sourceProvider, diagnosticMessageSink, collectionFactory));
 }
Ejemplo n.º 11
0
        public ElasticTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink, IXunitTestCollectionFactory collectionFactory = null) : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
        {
            var a       = Assembly.Load(new AssemblyName(assemblyInfo.Name));
            var options = a.GetCustomAttribute <ElasticXunitConfigurationAttribute>()?.Options ?? new ElasticXunitRunOptions();

            this.Options = options;
        }
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="sourceProvider">The source information provider.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public TestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                       ISourceInformationProvider sourceProvider,
                                       IMessageAggregator messageAggregator)
        {
            Guard.ArgumentNotNull("assemblyInfo", assemblyInfo);
            Guard.ArgumentNotNull("sourceProvider", sourceProvider);

            Aggregator      = messageAggregator ?? MessageAggregator.Instance;
            AssemblyInfo    = assemblyInfo;
            DisposalTracker = new DisposalTracker();
            SourceProvider  = sourceProvider;

            targetFramework = new Lazy <string>(() =>
            {
                string result = null;

                var attrib = AssemblyInfo.GetCustomAttributes(typeof(TargetFrameworkAttribute)).FirstOrDefault();
                if (attrib != null)
                {
                    result = attrib.GetConstructorArguments().Cast <string>().First();
                }

                return(result ?? "");
            });
        }
        public IntegrationTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            TestFrameworkDisplayName = "Integration Test Framework";

            _testAssembly = new TestAssembly(assemblyInfo);
        }
 public KuduXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                         ISourceInformationProvider sourceProvider,
                                         IMessageSink diagnosticMessageSink,
                                         IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
 }
Ejemplo n.º 15
0
        public BenchmarkTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
            : base(assemblyInfo, sourceInformationProvider, diagnosticMessageSink)
        {
            var testAssembly = new TestAssembly(assemblyInfo, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

            testCollectionFactory = new CollectionPerClassTestCollectionFactory(testAssembly, DiagnosticMessageSink);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="T:Xunit.VisualStudioSourceInformationProvider"/>).</param>
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public XunitFrontController(string assemblyFileName,
                                    string configFileName   = null,
                                    bool shadowCopy         = true,
                                    string shadowCopyFolder = null,
                                    ISourceInformationProvider sourceInformationProvider = null,
                                    IMessageSink diagnosticMessageSink = null)
        {
            this.assemblyFileName          = assemblyFileName;
            this.configFileName            = configFileName;
            this.shadowCopy                = shadowCopy;
            this.shadowCopyFolder          = shadowCopyFolder;
            this.sourceInformationProvider = sourceInformationProvider;
            this.diagnosticMessageSink     = diagnosticMessageSink ?? new NullMessageSink();

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
#if !XAMARIN && !WINDOWS_PHONE_APP && !WINDOWS_PHONE
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
#else
                this.sourceInformationProvider = new NullSourceInformationProvider();
#endif
                toDispose.Push(this.sourceInformationProvider);
            }
        }
Ejemplo n.º 17
0
 public KuduXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                         ISourceInformationProvider sourceProvider,
                                         IMessageSink diagnosticMessageSink,
                                         IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
 }
Ejemplo n.º 18
0
        Xunit2Discoverer(AppDomainSupport appDomainSupport,
                         ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder,
                         IMessageSink diagnosticMessageSink,
                         bool verifyAssembliesOnDisk)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            if (verifyAssembliesOnDisk)
                Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

#if PLATFORM_DOTNET
            CanUseAppDomains = false;
#else
            CanUseAppDomains = !IsDotNet(xunitExecutionAssemblyPath);
#endif

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            var appDomainAssembly = assemblyFileName ?? xunitExecutionAssemblyPath;
            appDomain = AppDomainManagerFactory.Create(appDomainSupport != AppDomainSupport.Denied && CanUseAppDomains, appDomainAssembly, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = appDomain.CreateObject<IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            framework = appDomain.CreateObject<ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
        public AutofacTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            var testAssembly = new TestAssembly(assemblyInfo);

            _testCollectionFactory = new CollectionPerClassTestCollectionFactory(testAssembly, diagnosticMessageSink);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="useAppDomain">Determines whether tests should be run in a separate app domain.</param>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        /// <param name="verifyTestAssemblyExists">Determines whether or not the existence of the test assembly is verified.</param>
        public Xunit2(bool useAppDomain,
                      ISourceInformationProvider sourceInformationProvider,
                      string assemblyFileName,
                      string configFileName              = null,
                      bool shadowCopy                    = true,
                      string shadowCopyFolder            = null,
                      IMessageSink diagnosticMessageSink = null,
                      bool verifyTestAssemblyExists      = true)
            : base(useAppDomain, sourceInformationProvider, assemblyFileName, configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink, verifyTestAssemblyExists)
        {
#if ANDROID
            var assemblyName = Assembly.Load(assemblyFileName).GetName();
#elif WINDOWS_PHONE_APP || WINDOWS_PHONE || DOTNETCORE
            // Make sure we only use the short form for WPA81
            var an = Assembly.Load(new AssemblyName {
                Name = Path.GetFileNameWithoutExtension(assemblyFileName)
            }).GetName();
            var assemblyName = new AssemblyName {
                Name = an.Name, Version = an.Version
            };
#else
            var assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);
#endif
            executor = Framework.GetExecutor(assemblyName);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Xunit.Sdk.XunitTestFrameworkExecutor"/> class.
 /// </summary>
 /// <param name="assemblyName">Name of the test assembly.</param><param name="sourceInformationProvider">The source line number information provider.</param><param name="diagnosticMessageSink">The message sink to report diagnostic messages to.</param>
 public ParallelTestFrameworkExecutor(
     AssemblyName assemblyName,
     ISourceInformationProvider sourceInformationProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
 }
Ejemplo n.º 22
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);

#if PLATFORM_LINUX || PLATFORM_MACOS
            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

            assemblyInfo = new Xunit.Sdk.ReflectionAssemblyInfo(assemblyFileName);
            framework    = new Xunit.Sdk.TestFrameworkProxy(assemblyInfo, sourceInformationProvider);
            discoverer   = framework.GetDiscoverer(assemblyInfo);
#else
            Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
            {
                assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);
            }

            framework  = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
#endif
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        public Xunit2(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true)
            : base(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy)
        {
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);

            executor = Framework.GetExecutor(assemblyName);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="appDomainSupport">Determines whether tests should be run in a separate app domain.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="T:Xunit.VisualStudioSourceInformationProvider"/>).</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public XunitFrontController(AppDomainSupport appDomainSupport,
                                    string assemblyFileName,
                                    string configFileName   = null,
                                    bool shadowCopy         = true,
                                    string shadowCopyFolder = null,
                                    ISourceInformationProvider sourceInformationProvider = null,
                                    IMessageSink diagnosticMessageSink = null)
        {
            this.appDomainSupport          = appDomainSupport;
            this.assemblyFileName          = assemblyFileName;
            this.configFileName            = configFileName;
            this.shadowCopy                = shadowCopy;
            this.shadowCopyFolder          = shadowCopyFolder;
            this.sourceInformationProvider = sourceInformationProvider;
            this.diagnosticMessageSink     = diagnosticMessageSink ?? new NullMessageSink();

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
#if NETSTANDARD1_1
                this.sourceInformationProvider = new NullSourceInformationProvider();
#else
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
#endif
                toDispose.Push(this.sourceInformationProvider);
            }
        }
Ejemplo n.º 25
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
#if !ANDROID
            Guard.ArgumentValid("xunitExecutionAssemblyPath", "File not found: " + xunitExecutionAssemblyPath, File.Exists(xunitExecutionAssemblyPath));
#endif
            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

#if !ANDROID
            var name = AssemblyName.GetAssemblyName(xunitExecutionAssemblyPath);
            var testFrameworkAssemblyName = name.FullName;
#else
            var name = Assembly.Load(xunitExecutionAssemblyPath);
            var testFrameworkAssemblyName = name.FullName;
#endif

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
            {
                assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);
            }

            framework  = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
Ejemplo n.º 26
0
 public CustomDiscoverer(IAssemblyInfo assemblyInfo,
                         ISourceInformationProvider sourceProvider,
                         IMessageSink diagnosticMessageSink,
                         IXunitTestCollectionFactory collectionFactory = null) : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
     tests = new HashSet <string>();
 }
 public KuduXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                         ISourceInformationProvider sourceProvider,
                                         IMessageSink diagnosticMessageSink,
                                         IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
     _privateEnv = typeof(KuduXunitTestFrameworkDiscoverer).Assembly.GetType("Kudu.TestHarness.Antares.AntaresEnvironment") != null;
 }
Ejemplo n.º 28
0
 public PerfTestDiscoverer(
     IAssemblyInfo assemblyInfo,
     ISourceInformationProvider sourceProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     _testConfig = new TestConfig();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkExecutor"/> class.
        /// </summary>
        /// <param name="assemblyName">Name of the test assembly.</param>
        /// <param name="sourceInformationProvider">The source line number information provider.</param>
        public XunitTestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider)
        {
            this.sourceInformationProvider = sourceInformationProvider;

            var assembly = Assembly.Load(assemblyName);
            assemblyInfo = Reflector.Wrap(assembly);
            assemblyFileName = assemblyInfo.AssemblyPath;
        }
Ejemplo n.º 30
0
 public PerfTestDiscoverer(
     IAssemblyInfo assemblyInfo,
     ISourceInformationProvider sourceProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     _testConfig = new TestConfig();
 }
 public KuduXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                         ISourceInformationProvider sourceProvider,
                                         IMessageSink diagnosticMessageSink,
                                         IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
     _privateEnv = typeof(KuduXunitTestFrameworkDiscoverer).Assembly.GetType("Kudu.TestHarness.Antares.AntaresEnvironment") != null;
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Xunit2Discoverer"/> class.
 /// </summary>
 /// <param name="sourceInformationProvider">The source code information provider.</param>
 /// <param name="assemblyInfo">The assembly to use for discovery</param>
 /// <param name="xunitExecutionAssemblyPath">The path on disk of xunit.execution.dll; if <c>null</c>, then
 /// the location of xunit.execution.dll is implied based on the location of the test assembly</param>
 /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
 /// will be automatically (randomly) generated</param>
 /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
 public Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string xunitExecutionAssemblyPath  = null,
                         string shadowCopyFolder            = null,
                         IMessageSink diagnosticMessageSink = null)
     : this(sourceInformationProvider, assemblyInfo, null, xunitExecutionAssemblyPath ?? GetXunitExecutionAssemblyPath(assemblyInfo), null, true, shadowCopyFolder, diagnosticMessageSink)
 {
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkExecutor"/> class.
        /// </summary>
        /// <param name="assemblyFileName">Path of the test assembly.</param>
        /// <param name="sourceInformationProvider">The source line number information provider.</param>
        public XunitTestFrameworkExecutor(string assemblyFileName, ISourceInformationProvider sourceInformationProvider)
        {
            this.assemblyFileName = assemblyFileName;
            this.sourceInformationProvider = sourceInformationProvider;

            var assembly = Assembly.Load(AssemblyName.GetAssemblyName(assemblyFileName));
            assemblyInfo = Reflector.Wrap(assembly);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit1"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">Source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        public Xunit1(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true, string shadowCopyFolder = null)
        {
            this.sourceInformationProvider = sourceInformationProvider;
            this.assemblyFileName          = assemblyFileName;
            this.configFileName            = configFileName;

            executor = CreateExecutor(assemblyFileName, configFileName, shadowCopy, shadowCopyFolder);
        }
Ejemplo n.º 35
0
 public TestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink, IList <AssemblyLoaderAttribute> assemblyLoaders, IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
     foreach (var assemblyLoader in assemblyLoaders)
     {
         DisposalTracker.Add(assemblyLoader);
     }
 }
 public ObservationDiscoverer(IAssemblyInfo assemblyInfo,
                              ISourceInformationProvider sourceProvider,
                              IMessageSink diagnosticMessageSink)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     var testAssembly = new TestAssembly(assemblyInfo, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
     testCollectionFactory = new CollectionPerClassTestCollectionFactory(testAssembly, diagnosticMessageSink);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Xunit2Discoverer"/> class.
 /// </summary>
 /// <param name="appDomainSupport">Determines whether tests should be run in a separate app domain.</param>
 /// <param name="sourceInformationProvider">The source code information provider.</param>
 /// <param name="assemblyInfo">The assembly to use for discovery</param>
 /// <param name="xunitExecutionAssemblyPath">The path on disk of xunit.execution.dll; if <c>null</c>, then
 /// the location of xunit.execution.dll is implied based on the location of the test assembly</param>
 /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
 /// will be automatically (randomly) generated</param>
 /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
 /// <param name="verifyAssembliesOnDisk">Determines whether or not to check for the existence of assembly files.</param>
 public Xunit2Discoverer(AppDomainSupport appDomainSupport,
                         ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string xunitExecutionAssemblyPath = null,
                         string shadowCopyFolder = null,
                         IMessageSink diagnosticMessageSink = null,
                         bool verifyAssembliesOnDisk = true)
     : this(appDomainSupport, sourceInformationProvider, assemblyInfo, null, xunitExecutionAssemblyPath ?? GetXunitExecutionAssemblyPath(appDomainSupport, assemblyInfo), null, true, shadowCopyFolder, diagnosticMessageSink, verifyAssembliesOnDisk)
 { }
Ejemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Xunit2Discoverer"/> class.
 /// </summary>
 /// <param name="appDomainSupport">Determines whether tests should be run in a separate app domain.</param>
 /// <param name="sourceInformationProvider">The source code information provider.</param>
 /// <param name="assemblyInfo">The assembly to use for discovery</param>
 /// <param name="xunitExecutionAssemblyPath">The path on disk of xunit.execution.dll; if <c>null</c>, then
 /// the location of xunit.execution.dll is implied based on the location of the test assembly</param>
 /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
 /// will be automatically (randomly) generated</param>
 /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
 /// <param name="verifyAssembliesOnDisk">Determines whether or not to check for the existence of assembly files.</param>
 public Xunit2Discoverer(AppDomainSupport appDomainSupport,
                         ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string xunitExecutionAssemblyPath = null,
                         string shadowCopyFolder = null,
                         IMessageSink diagnosticMessageSink = null,
                         bool verifyAssembliesOnDisk = true)
     : this(appDomainSupport, sourceInformationProvider, assemblyInfo, null, xunitExecutionAssemblyPath ?? GetXunitExecutionAssemblyPath(appDomainSupport, assemblyInfo), null, true, shadowCopyFolder, diagnosticMessageSink, verifyAssembliesOnDisk)
 { }
Ejemplo n.º 39
0
 public TestFrameworkExecutor(
     Logger logger,
     AssemblyName assemblyName,
     ISourceInformationProvider sourceInformationProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
     m_logger = logger;
 }
 public ScenarioReportingXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                                      ISourceInformationProvider sourceProvider,
                                                      IMessageSink diagnosticMessageSink,
                                                      IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     DiscovererTypeCache[typeof(FactAttribute)]   = typeof(ScenarioFactAttributeDiscoverer);
     DiscovererTypeCache[typeof(TheoryAttribute)] = typeof(ScenarioTheoryAttributeDiscoverer);
 }
Ejemplo n.º 41
0
 public AutofacTestFrameworkExecutor(AssemblyName assemblyName,
                                     IContainer container,
                                     ISourceInformationProvider sourceInformationProvider,
                                     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
     _container    = container;
     _testAssembly = new TestAssembly(AssemblyInfo);
 }
Ejemplo n.º 42
0
 public FusonicTestFrameworkDiscoverer(
     IAssemblyInfo assemblyInfo,
     ISourceInformationProvider sourceProvider,
     IMessageSink diagnosticMessageSink,
     IXunitTestCollectionFactory?collectionFactory = null) : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
     DiscovererTypeCache[typeof(FactAttribute)]   = typeof(FusonicFactDiscoverer);
     DiscovererTypeCache[typeof(TheoryAttribute)] = typeof(FusonicTheoryDiscoverer);
 }
Ejemplo n.º 43
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit1"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">Source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        public Xunit1(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true)
        {
            this.sourceInformationProvider = sourceInformationProvider;
            this.assemblyFileName          = assemblyFileName;
            this.configFileName            = configFileName;

            executor       = CreateExecutor(assemblyFileName, configFileName, shadowCopy);
            testCollection = new Xunit1TestCollection(assemblyFileName);
        }
Ejemplo n.º 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTestFrameworkExecutor"/> class.
 /// </summary>
 /// <param name="assemblyName">Name of the test assembly.</param>
 /// <param name="configFileName">The test configuration file.</param>
 /// <param name="sourceInformationProvider">The source line number information provider.</param>
 /// <param name="diagnosticMessageSink">The message sink to report diagnostic messages to.</param>
 public XunitTestFrameworkExecutor(AssemblyName assemblyName,
                                   string configFileName,
                                   ISourceInformationProvider sourceInformationProvider,
                                   IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
     TestAssembly = new TestAssembly(AssemblyInfo, configFileName, assemblyName.Version);
     discoverer   = new Lazy <XunitTestFrameworkDiscoverer>(() => new XunitTestFrameworkDiscoverer(AssemblyInfo, configFileName, SourceInformationProvider, DiagnosticMessageSink));
 }
Ejemplo n.º 45
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit1"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">Source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        public Xunit1(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true)
        {
            this.sourceInformationProvider = sourceInformationProvider;
            this.assemblyFileName = assemblyFileName;
            this.configFileName = configFileName;

            executor = CreateExecutor(assemblyFileName, configFileName, shadowCopy);
            testCollection = new Xunit1TestCollection(assemblyFileName);
        }
Ejemplo n.º 46
0
 // Used by Xunit2 when initializing for both discovery and execution.
 internal Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                           string assemblyFileName,
                           string configFileName,
                           bool shadowCopy,
                           string shadowCopyFolder            = null,
                           IMessageSink diagnosticMessageSink = null)
     : this(sourceInformationProvider, null, assemblyFileName, GetXunitExecutionAssemblyPath(assemblyFileName), configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink)
 {
 }
 public SpecThisTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink, IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     IAttributeInfo collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault<IAttributeInfo>();
     bool flag = collectionBehaviorAttribute != null && collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");
     string configurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
     TestAssembly testAssembly = new TestAssembly(assemblyInfo, configurationFile);
     this.TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, (ITestAssembly)testAssembly);
     this.TestFrameworkDisplayName = string.Format("{0} [{1}, {2}]", XunitTestFrameworkDiscoverer.DisplayName, this.TestCollectionFactory.DisplayName, flag ? "non-parallel" : "parallel");
 }
Ejemplo n.º 48
0
 // Used by Xunit2 when initializing for both discovery and execution.
 internal Xunit2Discoverer(AppDomainSupport appDomainSupport,
                           ISourceInformationProvider sourceInformationProvider,
                           string assemblyFileName,
                           string configFileName,
                           bool shadowCopy,
                           string shadowCopyFolder = null,
                           IMessageSink diagnosticMessageSink = null,
                           bool verifyAssembliesOnDisk = true)
     : this(appDomainSupport, sourceInformationProvider, null, assemblyFileName, GetXunitExecutionAssemblyPath(appDomainSupport, assemblyFileName, verifyAssembliesOnDisk), configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink, verifyAssembliesOnDisk)
 { }
Ejemplo n.º 49
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        public Xunit2(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true, string shadowCopyFolder = null)
            : base(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy, shadowCopyFolder)
        {
#if !ANDROID
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);
#else
            var assm = Assembly.Load(assemblyFileName);
            AssemblyName assemblyName = assm.GetName();
#endif
            executor = Framework.GetExecutor(assemblyName);
        }
Ejemplo n.º 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public TestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                       ISourceInformationProvider sourceProvider,
                                       IMessageAggregator messageAggregator)
        {
            Guard.ArgumentNotNull("assemblyInfo", assemblyInfo);
            Guard.ArgumentNotNull("sourceProvider", sourceProvider);

            Aggregator = messageAggregator ?? MessageAggregator.Instance;
            AssemblyInfo = assemblyInfo;
            DisposalTracker = new DisposalTracker();
            SourceProvider = sourceProvider;
        }
Ejemplo n.º 51
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, string assemblyFileName, string xunit2AssemblyPath, string configFileName, bool shadowCopy)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            Guard.ArgumentValid("xunit2AssemblyPath", "File not found: " + xunit2AssemblyPath, File.Exists(xunit2AssemblyPath));

            framework = new AppDomainTestFramework(sourceInformationProvider, assemblyFileName, xunit2AssemblyPath, "Xunit.Sdk.XunitTestFramework", configFileName, shadowCopy);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = framework.CreateRemoteObject<IAssemblyInfo>("Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        public Xunit2(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string configFileName = null, bool shadowCopy = true, string shadowCopyFolder = null)
            : base(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy, shadowCopyFolder)
        {
#if ANDROID
            var assm = Assembly.Load(assemblyFileName);
            var assemblyName = assm.GetName();
#elif WINDOWS_PHONE_APP || WINDOWS_PHONE || ASPNET50 || ASPNETCORE50
            var assm = Assembly.Load(new AssemblyName { Name = Path.GetFileNameWithoutExtension(assemblyFileName) });
            var assemblyName = new AssemblyName { Name = assm.GetName().Name };
#else
            var assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);
#endif
            executor = Framework.GetExecutor(assemblyName);
        }
Ejemplo n.º 53
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IXunitTestCollectionFactory collectionFactory,
                                            IMessageAggregator messageAggregator)
        {
            Guard.ArgumentNotNull("assemblyInfo", assemblyInfo);
            Guard.ArgumentNotNull("sourceProvider", sourceProvider);

            this.assemblyInfo = assemblyInfo;
            this.sourceProvider = sourceProvider;
            this.messageAggregator = messageAggregator ?? MessageAggregator.Instance;

            TestCollectionFactory = collectionFactory ?? GetTestCollectionFactory(this.assemblyInfo);
            TestFrameworkDisplayName = String.Format("{0} [{1}, non-parallel]", DisplayName, TestCollectionFactory.DisplayName);
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IXunitTestCollectionFactory collectionFactory,
                                            IMessageAggregator messageAggregator)
            : base(assemblyInfo, sourceProvider, messageAggregator)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute == null ? false : collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            TestCollectionFactory = collectionFactory ?? GetTestCollectionFactory(this.AssemblyInfo, collectionBehaviorAttribute);
            TestFrameworkDisplayName = String.Format("{0} [{1}, {2}]",
                                                     DisplayName,
                                                     TestCollectionFactory.DisplayName,
                                                     disableParallelization ? "non-parallel" : "parallel");
        }
Ejemplo n.º 55
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="VisualStudioSourceInformationProvider"/>).</param>
        /// tests to be discovered and run without locking assembly files on disk.</param>
        public XunitFrontController(string assemblyFileName, string configFileName = null, bool shadowCopy = true, ISourceInformationProvider sourceInformationProvider = null)
        {
            this.assemblyFileName = assemblyFileName;
            this.configFileName = configFileName;
            this.shadowCopy = shadowCopy;
            this.sourceInformationProvider = sourceInformationProvider;

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
                toDispose.Push(this.sourceInformationProvider);
            }
        }
Ejemplo n.º 56
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="appDomainSupport">Determines whether tests should be run in a separate app domain.</param>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        /// <param name="verifyTestAssemblyExists">Determines whether or not the existence of the test assembly is verified.</param>
        public Xunit2(AppDomainSupport appDomainSupport,
                      ISourceInformationProvider sourceInformationProvider,
                      string assemblyFileName,
                      string configFileName = null,
                      bool shadowCopy = true,
                      string shadowCopyFolder = null,
                      IMessageSink diagnosticMessageSink = null,
                      bool verifyTestAssemblyExists = true)
            : base(appDomainSupport, sourceInformationProvider, assemblyFileName, configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink, verifyTestAssemblyExists)
        {
#if PLATFORM_DOTNET
            var an = Assembly.Load(new AssemblyName { Name = Path.GetFileNameWithoutExtension(assemblyFileName) }).GetName();
            var assemblyName = new AssemblyName { Name = an.Name, Version = an.Version };
#else
            var assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);
#endif
            executor = Framework.GetExecutor(assemblyName);
        }
        readonly Dictionary<Type, Type> discovererTypeCache = new Dictionary<Type, Type>(); // key is a Type that is or derives from FactAttribute

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IMessageSink diagnosticMessageSink,
                                            IXunitTestCollectionFactory collectionFactory = null)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute != null && collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            string config = null;
#if !PLATFORM_DOTNET
            config = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
            var testAssembly = new TestAssembly(assemblyInfo, config);

            TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, testAssembly);
            TestFrameworkDisplayName = $"{DisplayName} [{TestCollectionFactory.DisplayName}, {(disableParallelization ? "non-parallel" : "parallel")}]";
        }
Ejemplo n.º 58
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="VisualStudioSourceInformationProvider"/>).</param>
        /// tests to be discovered and run without locking assembly files on disk.</param>
        public XunitFrontController(string assemblyFileName, string configFileName = null, bool shadowCopy = true, ISourceInformationProvider sourceInformationProvider = null)
        {
            Guard.FileExists("assemblyFileName", assemblyFileName);
            var xunit1Path = Path.Combine(Path.GetDirectoryName(assemblyFileName), "xunit.dll");
            var xunit2Path = Path.Combine(Path.GetDirectoryName(assemblyFileName), "xunit2.dll");

            if (sourceInformationProvider == null)
            {
                sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
                createdSourceInformationProvider = sourceInformationProvider;
            }

            if (File.Exists(xunit2Path))
                innerController = new Xunit2(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy);
            else if (File.Exists(xunit1Path))
                innerController = new Xunit1(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy);
            else
                throw new ArgumentException("Unknown test framework: Could not find xunit.dll or xunit2.dll.", assemblyFileName);
        }
Ejemplo n.º 59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit2"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public Xunit2(ISourceInformationProvider sourceInformationProvider,
                      string assemblyFileName,
                      string configFileName = null,
                      bool shadowCopy = true,
                      string shadowCopyFolder = null,
                      IMessageSink diagnosticMessageSink = null)
            : base(sourceInformationProvider, assemblyFileName, configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink)
        {
#if ANDROID
            var assm = Assembly.Load(assemblyFileName);
            var assemblyName = assm.GetName();
#elif WINDOWS_PHONE_APP || WINDOWS_PHONE || DNX451 || DNXCORE50
            var assm = Assembly.Load(new AssemblyName { Name = Path.GetFileNameWithoutExtension(assemblyFileName) });
            var assemblyName = new AssemblyName { Name = assm.GetName().Name, Version = new Version(0, 0, 0, 0) };
#else
            var assemblyName = AssemblyName.GetAssemblyName(assemblyFileName);
#endif
            executor = Framework.GetExecutor(assemblyName);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IMessageSink diagnosticMessageSink,
                                            IXunitTestCollectionFactory collectionFactory = null)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute == null ? false : collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            string config = null;
#if !WINDOWS_PHONE_APP && !WINDOWS_PHONE && !DNXCORE50
            config = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
            var testAssembly = new TestAssembly(assemblyInfo, config);

            TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, testAssembly);
            TestFrameworkDisplayName = string.Format("{0} [{1}, {2}]",
                                                     DisplayName,
                                                     TestCollectionFactory.DisplayName,
                                                     disableParallelization ? "non-parallel" : "parallel");
        }