Пример #1
0
        Xunit2Discoverer(bool useAppDomain,
                         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);
            }

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            var appDomainAssembly = assemblyFileName ?? xunitExecutionAssemblyPath;

            appDomain = AppDomainManagerFactory.Create(useAppDomain, 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);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Xunit1Executor" /> class.
 /// </summary>
 /// <param name="useAppDomain">Determines whether tests should be run in a separate app domain.</param>
 /// <param name="testAssemblyFileName">The filename of the test assembly.</param>
 /// <param name="configFileName">The filename of the configuration file.</param>
 /// <param name="shadowCopy">Set to <c>true</c> to enable shadow copying the assemblies.</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 Xunit1Executor(bool useAppDomain,
                       string testAssemblyFileName,
                       string configFileName   = null,
                       bool shadowCopy         = true,
                       string shadowCopyFolder = null)
 {
     appDomain                = AppDomainManagerFactory.Create(useAppDomain, testAssemblyFileName, configFileName, shadowCopy, shadowCopyFolder);
     xunitAssemblyPath        = GetXunitAssemblyPath(testAssemblyFileName);
     xunitAssemblyName        = AssemblyName.GetAssemblyName(xunitAssemblyPath);
     executor                 = CreateObject("Xunit.Sdk.Executor", testAssemblyFileName);
     TestFrameworkDisplayName = string.Format(CultureInfo.InvariantCulture, "xUnit.net {0}", AssemblyName.GetAssemblyName(xunitAssemblyPath).Version);
 }
Пример #3
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 NETFRAMEWORK
            // Only safe to assume the execution reference is copied in a desktop project
            if (verifyAssembliesOnDisk)
            {
                Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);
            }

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

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

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

#if NETFRAMEWORK
            var runnerUtilityAssemblyLocation = Path.GetDirectoryName(typeof(AssemblyHelper).Assembly.GetLocalCodeBase());
            assemblyHelper = AppDomain.CreateObjectFrom <AssemblyHelper>(typeof(AssemblyHelper).Assembly.Location, typeof(AssemblyHelper).FullName, runnerUtilityAssemblyLocation);
#endif

            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);

            RemoteDiscoverer = Framework.GetDiscoverer(assemblyInfo);
        }