public static List <string> GetExtensions(ITestDiscoverer discoverer) { var atts = discoverer.GetType().GetCustomAttributes(true).OfType <FileExtensionAttribute>().ToList(); var extensions = atts.Select(att => att.FileExtension).ToList(); return(extensions); }
public static List <string> GetSources(string folder, ITestDiscoverer discoverer) { var extensions = GetExtensions(discoverer); var sources = Directory.EnumerateFiles(folder).Where(file => extensions.Contains(Path.GetExtension(file))).ToList(); return(sources); }
private static void DiscoverTests(TestEnvironment testEnv, string[] sources, MockRunSettings runSettings, TestInfo[] expectedTests) { var discoveryContext = new MockDiscoveryContext(runSettings); var discoverySink = new MockTestCaseDiscoverySink(); var logger = new MockMessageLogger(); ITestDiscoverer discoverer = null; switch (testEnv.TestFramework) { case FrameworkPytest: discoverer = new PytestTestDiscoverer(); break; case FrameworkUnittest: discoverer = new UnittestTestDiscoverer(); break; default: Assert.Fail($"unknown testframework: {testEnv.TestFramework.ToString()}"); break; } discoverer.DiscoverTests(sources, discoveryContext, logger, discoverySink); ValidateDiscoveredTests(testEnv.TestFramework, discoverySink.Tests, expectedTests); }
public void VerifyLoading() { // Load the NUnit empty-assembly.dll once for this test nunittestDiscoverer = ((ITestDiscoverer) new NUnitTestDiscoverer()); nunittestDiscoverer.DiscoverTests( new[] { EmptyAssemblyPath }, new FakeDiscoveryContext(), new MessageLoggerStub(), this); }
public void VerifyLoading() { // Load the NUnit empty-assembly.dll once for this test nunittestDiscoverer = ((ITestDiscoverer)new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests( new[] { EmptyAssemblyPath}, new FakeDiscoveryContext(), new MessageLoggerStub(), this); }
public void LoadMockassembly() { // Sanity check to be sure we have the correct version of mock-assembly.dll Assert.That(NUnit.Tests.Assemblies.MockAssembly.Tests, Is.EqualTo(31), "The reference to mock-assembly.dll appears to be the wrong version"); // Load the NUnit mock-assembly.dll once for this test, saving // the list of test cases sent to the discovery sink nunittestDiscoverer = ((ITestDiscoverer) new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests(new[] { MockAssemblyPath }, null, this, this); }
public void LoadMockassembly() { // Sanity check to be sure we have the correct version of mock-assembly.dll Assert.That(NUnit.Tests.Assemblies.MockAssembly.Tests, Is.EqualTo(31), "The reference to mock-assembly.dll appears to be the wrong version"); // Load the NUnit mock-assembly.dll once for this test, saving // the list of test cases sent to the discovery sink nunittestDiscoverer = ((ITestDiscoverer)new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests(new[] { MockAssemblyPath}, null, this, this); }
static TestAdapter() { var testPlatformAdapterFileName = GetFileNames("DevTeam.TestPlatformAdapter.dll").First(); var icoConfigFileName = GetFileNames("DevTeam.TestEngine.dll.ioc").First(); #if !NETCOREAPP1_0 AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { var assemblyName = new AssemblyName(args.Name); foreach (var fileName in GetFileNames(assemblyName.Name + ".dll")) { try { return(Assembly.LoadFile(fileName)); } catch { // ignored } } return(null); }; var testPlatformAdapterAssembly = Assembly.LoadFile(testPlatformAdapterFileName); var testPlatformAdapterType = testPlatformAdapterAssembly.GetTypes().Single(i => i.Name == "TestAdapter"); #else AssemblyLoadContext.Default.Resolving += (ctx, assemblyName) => { foreach (var fileName in GetFileNames(assemblyName.Name + ".dll")) { try { return(ctx.LoadFromAssemblyPath(fileName)); } catch { // ignored } } return(null); }; var testPlatformAdapterAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(testPlatformAdapterFileName); var testPlatformAdapterType = testPlatformAdapterAssembly.ExportedTypes.Single(i => i.Name == "TestAdapter"); #endif var adapter = Activator.CreateInstance(testPlatformAdapterType, icoConfigFileName, ExecutorUri); TestDiscoverer = (ITestDiscoverer)adapter; TestExecutor = (ITestExecutor)adapter; }
/// <summary> /// This is the equivalent of "RunAll" functionality /// </summary> /// <param name="sources">Refers to the list of test sources passed to the test adapter from the client. (Client could be VS or command line)</param> /// <param name="runContext">Defines the settings related to the current run</param> /// <param name="frameworkHandle">Handle to framework. Used for recording results</param> public void RunTests(IEnumerable <string> sources, ITestDiscoverer discoverer) { ValidateArg.NotNull(sources, nameof(sources)); ValidateArg.NotNull(discoverer, nameof(discoverer)); var receiver = new TestReceiver(); discoverer.DiscoverTests(sources, /*discoveryContext*/ null, this.frameworkHandle, receiver); if (this.cancelRequested.WaitOne(0)) { return; } this.RunTests(receiver.Tests); }
public void LoadMockassembly() { // Sanity check to be sure we have the correct version of mock-assembly.dll Assert.That(NUnit.Tests.Assemblies.MockAssembly.TestsAtRuntime, Is.EqualTo(NUnit.Tests.Assemblies.MockAssembly.Tests), "The reference to mock-assembly.dll appears to be the wrong version"); TestCases = new List <TestCase>(); // Load the NUnit mock-assembly.dll once for this test, saving // the list of test cases sent to the discovery sink nunittestDiscoverer = ((ITestDiscoverer) new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests( new[] { MockAssemblyPath }, _context, new MessageLoggerStub(), this); }
public void VerifyLoading() { // Load the NUnit empty-assembly.dll once for this test nunittestDiscoverer = ((ITestDiscoverer) new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests(new[] { EmptyAssemblyPath }, null, this, this); }
public TestRunner() { _discoverer = null; }
public TestRunner(ITestDiscoverer discoverer) { _discoverer = discoverer; }
public void VerifyLoading() { // Load the NUnit empty-assembly.dll once for this test nunittestDiscoverer = ((ITestDiscoverer)new NUnit3TestDiscoverer()); nunittestDiscoverer.DiscoverTests(new[] { EmptyAssemblyPath}, null, this, this); }