diff --git a/.gitignore b/.gitignore index 8868dfd..4a2d91e 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,8 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store +*.ldf +*.mdf +/Backup +/UpgradeLog.htm +packages/ diff --git a/NUnitTestAdapter.sln b/NUnitTestAdapter.sln index d4e364d..d7defc6 100644 Binary files a/NUnitTestAdapter.sln and b/NUnitTestAdapter.sln differ diff --git a/src/NUnitTestAdapter/AssemblyRunner.cs b/src/NUnitTestAdapter/AssemblyRunner.cs index 52e8976..2032d33 100644 --- a/src/NUnitTestAdapter/AssemblyRunner.cs +++ b/src/NUnitTestAdapter/AssemblyRunner.cs @@ -2,6 +2,9 @@ // Copyright (c) 2013 NUnit Software. All rights reserved. // **************************************************************** +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + namespace NUnit.VisualStudio.TestAdapter { using System; @@ -46,16 +49,14 @@ namespace NUnit.VisualStudio.TestAdapter this.nunitFilter = MakeTestFilter(selectedTestCases); } + private readonly ITfsTestFilter TfsFilter; + // This constructor is used when the executor is called with a list of assemblies - public AssemblyRunner(TestLogger logger, string assemblyName, TFSTestFilter tfsFilter) + public AssemblyRunner(TestLogger logger, string assemblyName, ITfsTestFilter tfsFilter) : this(logger, assemblyName) { - if (tfsFilter.HasTfsFilterValue) - { - var filteredTestCases = tfsFilter.CheckFilter(this.LoadedTestCases); - this.nunitFilter = MakeTestFilter(filteredTestCases); + TfsFilter = tfsFilter; } - } private static SimpleNameFilter MakeTestFilter(IEnumerable ptestCases) { @@ -98,7 +99,7 @@ namespace NUnit.VisualStudio.TestAdapter try { #if LAUNCHDEBUGGER - Debugger.Launch(); + System.Diagnostics.Debugger.Launch(); #endif if (TryLoadAssembly()) { @@ -156,9 +157,14 @@ namespace NUnit.VisualStudio.TestAdapter if (!runner.Load(package)) return false; - + logger.SendMessage(TestMessageLevel.Informational,string.Format("Loading tests from {0}",package.FullName)); AddTestCases(runner.Test); - + if (TfsFilter==null || !TfsFilter.HasTfsFilterValue) + return true; + var filteredTestCases = TfsFilter.CheckFilter(this.LoadedTestCases); + var ptestCases = filteredTestCases as TestCase[] ?? filteredTestCases.ToArray(); + logger.SendMessage(TestMessageLevel.Informational, string.Format("TFS Filter detected: LoadedTestCases {0}, Filterered Test Cases {1}", LoadedTestCases.Count, ptestCases.Count())); + this.nunitFilter = MakeTestFilter(ptestCases); return true; } diff --git a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs index 0b88e1d..76de219 100644 --- a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs +++ b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs @@ -21,5 +21,5 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] [assembly: Guid("c0aad5e4-b486-49bc-b3e8-31e01be6fefe")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.7")] +[assembly: AssemblyFileVersion("1.0.0.7")] diff --git a/src/NUnitTestAdapter/TFSTestFilter.cs b/src/NUnitTestAdapter/TFSTestFilter.cs index 4c0ac67..ec57c4d 100644 --- a/src/NUnitTestAdapter/TFSTestFilter.cs +++ b/src/NUnitTestAdapter/TFSTestFilter.cs @@ -14,7 +14,14 @@ namespace NUnit.VisualStudio.TestAdapter { using System.Collections; - public class TFSTestFilter + public interface ITfsTestFilter + { + ITestCaseFilterExpression TfsTestCaseFilterExpression { get; } + bool HasTfsFilterValue { get; } + IEnumerable CheckFilter(IEnumerable tests); + } + + public class TFSTestFilter : ITfsTestFilter { /// /// Supported properties for filtering diff --git a/src/NUnitTestAdapterInstall/license.rtf b/src/NUnitTestAdapterInstall/license.rtf index fda1c64..09e9d8d 100644 Binary files a/src/NUnitTestAdapterInstall/license.rtf and b/src/NUnitTestAdapterInstall/license.rtf differ diff --git a/src/NUnitTestAdapterInstall/source.extension.vsixmanifest b/src/NUnitTestAdapterInstall/source.extension.vsixmanifest index a4e044c..ff6462e 100644 --- a/src/NUnitTestAdapterInstall/source.extension.vsixmanifest +++ b/src/NUnitTestAdapterInstall/source.extension.vsixmanifest @@ -3,8 +3,8 @@ NUnit Test Adapter Charlie Poole - 1.0.0.0 - NUnit adapter for integrated test execution under Visual Studio 2012 RTM, Update 1-4,and Visual Studio 2013 Preview. Compatible with NUnit 2.0 through 2.6.2. + 1.0.0.7 + NUnit adapter for integrated test execution under Visual Studio 2012 RTM, Update 1-4,and Visual Studio 2013. Compatible with NUnit 2.0 through 2.6.2. 1033 http://nunit.org/index.php?p=vsTestAdapter&r=2.6.2 license.rtf diff --git a/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs b/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs index 5cb6af4..a6e35fb 100644 --- a/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs +++ b/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Moq; using NUnit.Framework; @@ -87,5 +88,28 @@ namespace NUnit.VisualStudio.TestAdapter.Tests Assert.That(runner.NUnitFilter.IsEmpty, Is.False, "NUnitfilter should not be empty, we have added testcases"); Assert.That(runner.LoadedTestCases.Count, Is.EqualTo(2), "We should have had 2 converted MS test cases here"); } + + //[Test] + //public void HandleTfsFilterCorrectlyWhenFilterIsEmpty() + //{ + // var tfsfilter = new Mock(); + // tfsfilter.Setup(f => f.HasTfsFilterValue).Returns(false); + // var runner = new AssemblyRunner(new TestLogger(), "test", tfsfilter.Object); + // runner.AddTestCases(fakeTest1); + // runner.AddTestCases(fakeTest2); + + // Assert.That(runner.NUnitFilter.IsEmpty, Is.False, "NUnitfilter should not be empty, we have added testcases"); + // Assert.That(runner.LoadedTestCases.Count, Is.EqualTo(2), "We should have had 2 converted MS test cases here"); + //} + //[Test] + //public void HandleTfsFilterCorrectlyWhenNoFilter() + //{ + // var runner = new AssemblyRunner(new TestLogger(), "test", (TFSTestFilter)null); + // runner.AddTestCases(fakeTest1); + // runner.AddTestCases(fakeTest2); + + // Assert.That(runner.NUnitFilter.IsEmpty, Is.False, "NUnitfilter should not be empty, we have added testcases"); + // Assert.That(runner.LoadedTestCases.Count, Is.EqualTo(2), "We should have had 2 converted MS test cases here"); + //} } } diff --git a/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj b/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj index 337f02f..9a00afd 100644 --- a/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj +++ b/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj @@ -44,7 +44,11 @@ False ..\..\lib\mock-assembly.dll - + + ..\..\packages\Moq.4.1.1309.1617\lib\net40\Moq.dll + + + False ..\..\lib\nunit.core.dll @@ -89,6 +93,12 @@ NUnitTestAdapter + + + + + +