Exemple #1
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
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Xunit1Executor" /> class.
 /// </summary>
 /// <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>
 public Xunit1Executor(string testAssemblyFileName, string configFileName = null, bool shadowCopy = true)
 {
     appDomain                = new RemoteAppDomainManager(testAssemblyFileName, configFileName, shadowCopy);
     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);
 }
Exemple #5
0
        public DiaSessionWrapper(string assemblyFilename)
        {
            session = new DiaSession(assemblyFilename);

            var assemblyFileName = typeof(DiaSessionWrapperHelper).Assembly.GetLocalCodeBase();

            appDomainManager = new RemoteAppDomainManager(assemblyFileName, null, true, null);
            helper           = appDomainManager.CreateObject <DiaSessionWrapperHelper>(typeof(DiaSessionWrapperHelper).Assembly.FullName, typeof(DiaSessionWrapperHelper).FullName, assemblyFilename);
        }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppDomainTestFramework"/> class.
        /// </summary>
        /// <param name="sourceInformationProvider">The source code information provider.</param>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="testFrameworkFileName">The file path of the test framework assembly (i.e., xunit2.dll).</param>
        /// <param name="testFrameworkTypeName">The fully qualified type name of the implementation of <see cref="ITestFramework"/>
        /// in the test framework 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 AppDomainTestFramework(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string testFrameworkFileName, string testFrameworkTypeName, string configFileName = null, bool shadowCopy = true)
        {
            Guard.ArgumentNotNull("sourceInformationProvider", sourceInformationProvider);
            Guard.ArgumentNotNullOrEmpty("testFrameworkFileName", testFrameworkFileName);

            testFrameworkFileName = Path.GetFullPath(testFrameworkFileName);
            Guard.ArgumentValid("testFrameworkFileName", "File not found: " + testFrameworkFileName, File.Exists(testFrameworkFileName));

            SourceInformationProvider = sourceInformationProvider;

            // assemblyFileName might be null (during AST-based discovery), so pass along with the test
            // framework filename instead if we don't have an assembly under test yet.
            appDomain = new RemoteAppDomainManager(assemblyFileName ?? testFrameworkFileName, configFileName, shadowCopy);

            testFrameworkAssemblyName = AssemblyName.GetAssemblyName(testFrameworkFileName);
            testFramework             = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName.FullName, testFrameworkTypeName);
            testFramework.SourceInformationProvider = SourceInformationProvider;
        }