public void TraitProviderWithNoCategory() { var testFilter = new TfsTestFilter(null); var trait = TfsTestFilter.TraitProvider("JustKidding"); Assert.Null(trait); }
public void TraitProvider() { var testFilter = new TfsTestFilter(null); var trait = TfsTestFilter.TraitProvider("TestCategory"); Assert.NotNull(trait); }
public void PropertyValueProviderFqn() { var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "FullyQualifiedName"); Assert.AreSame("Test1", obj); }
public TestFilter ConvertTfsFilterToNUnitFilter(TfsTestFilter tfsFilter, List<TestCase> loadedTestCases) { var filteredTestCases = tfsFilter.CheckFilter(loadedTestCases); var testCases = filteredTestCases as TestCase[] ?? filteredTestCases.ToArray(); //TestLog.Info(string.Format("TFS Filter detected: LoadedTestCases {0}, Filterered Test Cases {1}", loadedTestCases.Count, testCases.Count())); return MakeTestFilter(testCases); }
public void PropertyValueProviderWithNoTraitsAndCategoryAsFilter() { var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "Category"); Assert.IsNull(obj); }
public void PropertyProvider() { var testfilter = new TfsTestFilter(null); var prop = TfsTestFilter.PropertyProvider("Priority"); Assert.NotNull(prop); prop = TfsTestFilter.PropertyProvider("TestCategory"); Assert.NotNull(prop); }
public void PropertyValueProviderCategoryWithNoTraits() { CheckTraitsSupported(); var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "TestCategory"); Assert.IsNull(obj); }
public void PropertyValueProviderWithOneCategoryAndCategoryAsFilter() { var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); tc.AddTrait("Category", "CI"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "Category"); Assert.AreSame("CI", obj); }
public void PropertyValueProviderCategoryWithOneCategory() { CheckTraitsSupported(); var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); tc.AddTrait("Category", "CI"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "TestCategory"); Assert.AreSame("CI", obj); }
public void PropertyValueProviderCategoryFail() { var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); tc.AddTrait("Category", "CI"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "Garbage"); Assert.Null(obj); }
public void PropertyValueProviderWithMultipleCategoriesAndCategoryAsFilter() { var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); tc.AddTrait("Category", "CI"); tc.AddTrait("Category", "MyOwn"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "Category") as string[]; Assert.IsNotNull(obj); Assert.AreEqual(obj.Length, 2); Assert.AreSame("CI", obj[0]); Assert.AreSame("MyOwn", obj[1]); }
public void PropertyValueProviderCategoryWithMultipleCategories() { CheckTraitsSupported(); var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX"); tc.AddTrait("Category", "CI"); tc.AddTrait("Category", "MyOwn"); var testFilter = new TfsTestFilter(null); var obj = TfsTestFilter.PropertyValueProvider(tc, "TestCategory") as string[]; Assert.IsNotNull(obj); Assert.AreEqual(obj.Length,2); Assert.AreSame("CI", obj[0]); Assert.AreSame("MyOwn",obj[1]); }
/// <summary> /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build /// to run either all or selected tests. In the latter case, a filter is provided /// as part of the run context. /// </summary> /// <param name="sources">Sources to be run.</param> /// <param name="runContext">Context to use when executing the tests.</param> /// <param name="frameworkHandle">Test log to send results and messages through</param> public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { TestLog.Initialize(frameworkHandle); if (RegistryFailure) { TestLog.SendErrorMessage(ErrorMsg); } Info("executing tests", "started"); try { // Ensure any channels registered by other adapters are unregistered CleanUpRegisteredChannels(); var tfsfilter = new TfsTestFilter(runContext); TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive); var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true; if (!tfsfilter.HasTfsFilterValue) { if (!(enableShutdown && !runContext.KeepAlive)) // Otherwise causes exception when run as commandline, illegal to enableshutdown when Keepalive is false, might be only VS2012 frameworkHandle.EnableShutdownAfterTestRun = enableShutdown; } foreach (var source in sources) { string sourceAssembly = source; if (!Path.IsPathRooted(sourceAssembly)) { sourceAssembly = Path.Combine(Environment.CurrentDirectory, sourceAssembly); } using (currentRunner = new AssemblyRunner(TestLog, sourceAssembly, tfsfilter,this)) { currentRunner.RunAssembly(frameworkHandle); } currentRunner = null; } } catch (Exception ex) { TestLog.SendErrorMessage("Exception thrown executing tests", ex); } finally { Info("executing tests", "finished"); } }
/// <summary> /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build /// to run either all or selected tests. In the latter case, a filter is provided /// as part of the run context. /// </summary> /// <param name="sources">Sources to be run.</param> /// <param name="runContext">Context to use when executing the tests.</param> /// <param name="frameworkHandle">Test log to send results and messages through</param> public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { #if LAUNCHDEBUGGER if (!Debugger.IsAttached) Debugger.Launch(); #endif Initialize(frameworkHandle); try { _tfsFilter = new TfsTestFilter(runContext); TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive); var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true; if (!_tfsFilter.HasTfsFilterValue) { if (!(enableShutdown && !runContext.KeepAlive)) // Otherwise causes exception when run as commandline, illegal to enableshutdown when Keepalive is false, might be only VS2012 frameworkHandle.EnableShutdownAfterTestRun = enableShutdown; } foreach (var source in sources) { var assemblyName = source; if (!Path.IsPathRooted(assemblyName)) assemblyName = Path.Combine(Environment.CurrentDirectory, assemblyName); TestLog.SendInformationalMessage("Running all tests in " + assemblyName); RunAssembly(assemblyName, frameworkHandle); } } catch (Exception ex) { if (ex is TargetInvocationException) ex = ex.InnerException; TestLog.SendErrorMessage("Exception thrown executing tests", ex); } finally { Info("executing tests", "finished"); Unload(); } }
/// <summary> /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build /// to run either all or selected tests. In the latter case, a filter is provided /// as part of the run context. /// </summary> /// <param name="sources">Sources to be run.</param> /// <param name="runContext">Context to use when executing the tests.</param> /// <param name="frameworkHandle">Test log to send results and messages through</param> public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { TestLog.Initialize(frameworkHandle); if (RegistryFailure) { TestLog.SendErrorMessage(ErrorMsg); } Info("executing tests", "started"); try { // Ensure any channels registered by other adapters are unregistered CleanUpRegisteredChannels(); var tfsfilter = new TfsTestFilter(runContext); TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive); var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true; if (!tfsfilter.HasTfsFilterValue) { frameworkHandle.EnableShutdownAfterTestRun = enableShutdown; } foreach (var source in sources) { using (currentRunner = new AssemblyRunner(TestLog, source, tfsfilter)) { currentRunner.RunAssembly(frameworkHandle); } currentRunner = null; } } catch (Exception ex) { TestLog.SendErrorMessage("Exception thrown executing tests", ex); } finally { Info("executing tests", "finished"); } }
public void Initialize(IRunContext runContext, IFrameworkHandle frameworkHandle) { base.Initialize(runContext, frameworkHandle); TestLog.Info(string.Format("NUnit Adapter {0}: Test execution started", AdapterVersion)); RunContext = runContext; FrameworkHandle = frameworkHandle; TfsFilter = new TfsTestFilter(runContext); // Ensure any channels registered by other adapters are unregistered CleanUpRegisteredChannels(); TestLog.Debug("Keepalive: " + runContext.KeepAlive); TestLog.Debug("UseVsKeepEngineRunning: " + Settings.UseVsKeepEngineRunning); bool enableShutdown = true; if (Settings.UseVsKeepEngineRunning ) { enableShutdown = !runContext.KeepAlive; } if (TfsFilter.IsEmpty) { if (!(enableShutdown && !runContext.KeepAlive)) // Otherwise causes exception when run as commandline, illegal to enableshutdown when Keepalive is false, might be only VS2012 frameworkHandle.EnableShutdownAfterTestRun = enableShutdown; } TestLog.Debug("EnableShutdown: " + enableShutdown.ToString()); }