From ae5ff75646570be5172aaad4649f4bb7281f6be7 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 3 Nov 2013 19:58:21 +0100 Subject: [PATCH 1/5] Updated VSIX to VS2013 --- NUnitTestAdapter.sln | Bin 5360 -> 5518 bytes .../NUnitTestAdapterInstall.csproj | 264 +++++++++--------- 2 files changed, 132 insertions(+), 132 deletions(-) diff --git a/NUnitTestAdapter.sln b/NUnitTestAdapter.sln index d4e364d7006cffb90b4df3de4aeb67d3fb5717ed..d7defc60452668b99dd1d1f111ac6957a9215ffe 100644 GIT binary patch delta 134 zcmeyM*{3~W8LKe^F9X-)jVzM3VGOAZMGVCZnGE?1c?=2+wm@viV8o!uU;xBMK(+x8 vngZE|AUzDeK$UqwoXb$kkP9+F8@mZ0-5_iNBtfQFf=rnFkwbFh0Rs^LkY^Yt delta 17 YcmeCv{-8Nw8KcqUeoo2Faf}8c06lsI)&Kwi diff --git a/src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj b/src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj index 28bd79c..bc9b65f 100644 --- a/src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj +++ b/src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj @@ -1,139 +1,139 @@ - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 11.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - Debug - AnyCPU - 2.0 - {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - {13ACDAEA-BAFE-4496-BC67-501E09A3247C} - Library - Properties - NUnitTestAdapter - NUnitTestAdapter - v4.5 - false - false - false - false - false - false - - - 4.0 - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - True - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - false - False - - - - - - - PreserveNewest - true - - - PreserveNewest - true - - - PreserveNewest - true - - - Designer - - - - - {8A85E26A-C706-48B1-BC36-06EBDE3EFD25} - NUnitTestAdapter - BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3b - DebugSymbolsProjectOutputGroup%3b - - - - - False - Microsoft .NET Framework 4.5 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 4.5 - true - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + 12.0 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + Debug + AnyCPU + 2.0 + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {13ACDAEA-BAFE-4496-BC67-501E09A3247C} + Library + Properties + NUnitTestAdapter + NUnitTestAdapter + v4.5 + false + false + false + false + false + false + + + 4.0 + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + True + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + false + False + + + + + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + Designer + + + + + {8A85E26A-C706-48B1-BC36-06EBDE3EFD25} + NUnitTestAdapter + BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3b + DebugSymbolsProjectOutputGroup%3b + + + + + False + Microsoft .NET Framework 4.5 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 4.5 + true + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + --> \ No newline at end of file From 7995b951b5a622cf3321bbee26770ee4ae5e61d6 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 3 Nov 2013 19:59:11 +0100 Subject: [PATCH 2/5] Added backup folders and upgradelogs to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9014b11..c50b4d4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ TestResults *.user *.ldf *.mdf +/Backup +/UpgradeLog.htm From cd41227cdd9c0042556af7afb7af0d290729528e Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 3 Nov 2013 22:32:57 +0100 Subject: [PATCH 3/5] Corrected handling of TfsFilter --- src/NUnitTestAdapter/AssemblyRunner.cs | 414 +++++++++--------- .../Properties/AssemblyInfo.cs | 4 +- src/NUnitTestAdapter/TFSTestFilter.cs | 33 +- src/NUnitTestAdapterInstall/license.rtf | Bin 2764 -> 2763 bytes .../source.extension.vsixmanifest | 4 +- .../AssemblyRunnerTests.cs | 206 +++++---- .../NUnitTestAdapterTests.csproj | 197 +++++---- src/NUnitTestAdapterTests/packages.config | 4 + 8 files changed, 456 insertions(+), 406 deletions(-) create mode 100644 src/NUnitTestAdapterTests/packages.config diff --git a/src/NUnitTestAdapter/AssemblyRunner.cs b/src/NUnitTestAdapter/AssemblyRunner.cs index 9ee70ad..419ffc4 100644 --- a/src/NUnitTestAdapter/AssemblyRunner.cs +++ b/src/NUnitTestAdapter/AssemblyRunner.cs @@ -1,205 +1,211 @@ -// **************************************************************** -// Copyright (c) 2013 NUnit Software. All rights reserved. -// **************************************************************** - -namespace NUnit.VisualStudio.TestAdapter -{ - using System; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - - using NUnit.Core; - using NUnit.Core.Filters; - using NUnit.Util; - - /// - /// The AssemblyRunner class executes tests in a single assembly - /// - public class AssemblyRunner : IDisposable - { - private TestRunner runner = new TestDomain(); - private TestLogger logger; - private string assemblyName; - - private TestFilter nunitFilter; - private List loadedTestCases; - private TestConverter testConverter; - - #region Constructors - - // This constructor is called by the others and is used directly for testing - public AssemblyRunner(TestLogger logger, string assemblyName) - { - this.logger = logger; - this.assemblyName = assemblyName; - this.testConverter = new TestConverter(logger, assemblyName); - this.loadedTestCases = new List(); - this.nunitFilter = TestFilter.Empty; - } - - // This constructor is used when the executor is called with a list of test cases - public AssemblyRunner(TestLogger logger, string assemblyName, IEnumerable selectedTestCases) - : this(logger, assemblyName) - { - this.nunitFilter = MakeTestFilter(selectedTestCases); - } - - // This constructor is used when the executor is called with a list of assemblies - public AssemblyRunner(TestLogger logger, string assemblyName, TFSTestFilter tfsFilter) - : this(logger, assemblyName) - { - if (tfsFilter.HasTfsFilterValue) - { - var filteredTestCases = tfsFilter.CheckFilter(this.LoadedTestCases); - this.nunitFilter = MakeTestFilter(filteredTestCases); - } - } - - private static SimpleNameFilter MakeTestFilter(IEnumerable ptestCases) - { - var filter = new SimpleNameFilter(); - foreach (TestCase testCase in ptestCases) - { - filter.Add(testCase.FullyQualifiedName); - } - return filter; - } - - #endregion - - #region Properties - - // TODO: Revise tests and remove - public TestFilter NUnitFilter - { - get { return nunitFilter; } - } - - // TODO: Revise tests and remove - public IList LoadedTestCases - { - get { return loadedTestCases; } - } - - // TODO: Revise tests and remove - public TestConverter TestConverter - { - get { return testConverter; } - } - - #endregion - - #region Public Methods - - public void RunAssembly(IFrameworkHandle testLog) - { - try - { -#if LAUNCHDEBUGGER - Debugger.Launch(); -#endif - if (TryLoadAssembly()) - { - var listener = new NUnitEventListener(testLog, this.TestConverter); - - try - { - runner.Run(listener, NUnitFilter, true, LoggingThreshold.Off); - } - catch (NullReferenceException) - { - // this happens during the run when CancelRun is called. - logger.SendDebugMessage("Nullref caught"); - } - finally - { - runner.Unload(); - } - } - else - { - logger.NUnitLoadError(assemblyName); - } - } - catch (System.BadImageFormatException) - { - // we skip the native c++ binaries that we don't support. - logger.AssemblyNotSupportedWarning(assemblyName); - } - catch (System.IO.FileNotFoundException ex) - { - // Probably from the GetExportedTypes in NUnit.core, attempting to find an assembly, not a problem if it is not NUnit here - logger.DependentAssemblyNotFoundWarning(ex.FileName, assemblyName); - } - catch (Exception ex) - { - logger.SendErrorMessage("Exception thrown executing tests in " + assemblyName, ex); - } - } - - public void CancelRun() - { - if (this.runner != null && this.runner.Running) - this.runner.CancelRun(); - } - - // Try to load the assembly and, if successful, populate - // the list of all loaded assemblies. As a side effect - // of calling TestConverter.ConvertTestCase, the converter's - // cache of all test cases is populated as well. All - // future calls to convert a test case may now use the cache. - private bool TryLoadAssembly() - { - var package = new TestPackage(assemblyName); - - if (!runner.Load(package)) - return false; - - AddTestCases(runner.Test); - - return true; - } - - // This method is public for testing purposes. - // TODO: Test by actually loading an assembly and make it private - public void AddTestCases(ITest test) - { - if (test.IsSuite) - foreach (ITest child in test.Tests) this.AddTestCases(child); - else - this.LoadedTestCases.Add(this.TestConverter.ConvertTestCase(test)); - } - - #endregion - - #region IDisposable - private bool _Disposed; - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!this._Disposed) - { - if (disposing) - { - if (this.TestConverter != null) - this.TestConverter.Dispose(); - } - } - this._Disposed = true; - } - - ~AssemblyRunner() - { - this.Dispose(false); - } - #endregion - } +// **************************************************************** +// Copyright (c) 2013 NUnit Software. All rights reserved. +// **************************************************************** + +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +namespace NUnit.VisualStudio.TestAdapter +{ + using System; + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + + using NUnit.Core; + using NUnit.Core.Filters; + using NUnit.Util; + + /// + /// The AssemblyRunner class executes tests in a single assembly + /// + public class AssemblyRunner : IDisposable + { + private TestRunner runner = new TestDomain(); + private TestLogger logger; + private string assemblyName; + + private TestFilter nunitFilter; + private List loadedTestCases; + private TestConverter testConverter; + + #region Constructors + + // This constructor is called by the others and is used directly for testing + public AssemblyRunner(TestLogger logger, string assemblyName) + { + this.logger = logger; + this.assemblyName = assemblyName; + this.testConverter = new TestConverter(logger, assemblyName); + this.loadedTestCases = new List(); + this.nunitFilter = TestFilter.Empty; + } + + // This constructor is used when the executor is called with a list of test cases + public AssemblyRunner(TestLogger logger, string assemblyName, IEnumerable selectedTestCases) + : this(logger, assemblyName) + { + 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, ITfsTestFilter tfsFilter) + : this(logger, assemblyName) + { + TfsFilter = tfsFilter; + } + + private static SimpleNameFilter MakeTestFilter(IEnumerable ptestCases) + { + var filter = new SimpleNameFilter(); + foreach (TestCase testCase in ptestCases) + { + filter.Add(testCase.FullyQualifiedName); + } + return filter; + } + + #endregion + + #region Properties + + // TODO: Revise tests and remove + public TestFilter NUnitFilter + { + get { return nunitFilter; } + } + + // TODO: Revise tests and remove + public IList LoadedTestCases + { + get { return loadedTestCases; } + } + + // TODO: Revise tests and remove + public TestConverter TestConverter + { + get { return testConverter; } + } + + #endregion + + #region Public Methods + + public void RunAssembly(IFrameworkHandle testLog) + { + try + { +#if LAUNCHDEBUGGER + Debugger.Launch(); +#endif + if (TryLoadAssembly()) + { + var listener = new NUnitEventListener(testLog, this.TestConverter); + + try + { + runner.Run(listener, NUnitFilter, true, LoggingThreshold.Off); + } + catch (NullReferenceException) + { + // this happens during the run when CancelRun is called. + logger.SendDebugMessage("Nullref caught"); + } + finally + { + runner.Unload(); + } + } + else + { + logger.NUnitLoadError(assemblyName); + } + } + catch (System.BadImageFormatException) + { + // we skip the native c++ binaries that we don't support. + logger.AssemblyNotSupportedWarning(assemblyName); + } + catch (System.IO.FileNotFoundException ex) + { + // Probably from the GetExportedTypes in NUnit.core, attempting to find an assembly, not a problem if it is not NUnit here + logger.DependentAssemblyNotFoundWarning(ex.FileName, assemblyName); + } + catch (Exception ex) + { + logger.SendErrorMessage("Exception thrown executing tests in " + assemblyName, ex); + } + } + + public void CancelRun() + { + if (this.runner != null && this.runner.Running) + this.runner.CancelRun(); + } + + // Try to load the assembly and, if successful, populate + // the list of all loaded assemblies. As a side effect + // of calling TestConverter.ConvertTestCase, the converter's + // cache of all test cases is populated as well. All + // future calls to convert a test case may now use the cache. + private bool TryLoadAssembly() + { + var package = new TestPackage(assemblyName); + + 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; + } + + // This method is public for testing purposes. + // TODO: Test by actually loading an assembly and make it private + public void AddTestCases(ITest test) + { + if (test.IsSuite) + foreach (ITest child in test.Tests) this.AddTestCases(child); + else + this.LoadedTestCases.Add(this.TestConverter.ConvertTestCase(test)); + } + + #endregion + + #region IDisposable + private bool _Disposed; + + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!this._Disposed) + { + if (disposing) + { + if (this.TestConverter != null) + this.TestConverter.Dispose(); + } + } + this._Disposed = true; + } + + ~AssemblyRunner() + { + this.Dispose(false); + } + #endregion + } } \ No newline at end of file diff --git a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs index 0b88e1d..915f1a6 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.5")] +[assembly: AssemblyFileVersion("1.0.0.5")] diff --git a/src/NUnitTestAdapter/TFSTestFilter.cs b/src/NUnitTestAdapter/TFSTestFilter.cs index a069a46..ec57c4d 100644 --- a/src/NUnitTestAdapter/TFSTestFilter.cs +++ b/src/NUnitTestAdapter/TFSTestFilter.cs @@ -1,7 +1,7 @@ -// **************************************************************** -// Copyright (c) 2013 NUnit Software. All rights reserved. -// **************************************************************** - +// **************************************************************** +// Copyright (c) 2013 NUnit Software. All rights reserved. +// **************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -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 @@ -66,14 +73,14 @@ namespace NUnit.VisualStudio.TestAdapter return testCaseFilterExpression ?? (testCaseFilterExpression = runContext.GetTestCaseFilter(supportedProperties, PropertyProvider)); } - } - - public bool HasTfsFilterValue - { - get - { - return TfsTestCaseFilterExpression != null && TfsTestCaseFilterExpression.TestCaseFilterValue != String.Empty; - } + } + + public bool HasTfsFilterValue + { + get + { + return TfsTestCaseFilterExpression != null && TfsTestCaseFilterExpression.TestCaseFilterValue != String.Empty; + } } public IEnumerable CheckFilter(IEnumerable tests) { diff --git a/src/NUnitTestAdapterInstall/license.rtf b/src/NUnitTestAdapterInstall/license.rtf index fda1c64e575e7747b41d20e476443bee2c7d8291..09e9d8d170aa4342716dc5eb7ad68fc15a2d4ce6 100644 GIT binary patch delta 14 WcmX>jdRlbCRc1pygN-*oa{>S^fCfJR delta 15 XcmX>tdPa1@RTcw1OY@C4K63&9Gkyks diff --git a/src/NUnitTestAdapterInstall/source.extension.vsixmanifest b/src/NUnitTestAdapterInstall/source.extension.vsixmanifest index a4e044c..dd81ca1 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.5 + 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 9a1f811..a6e35fb 100644 --- a/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs +++ b/src/NUnitTestAdapterTests/AssemblyRunnerTests.cs @@ -1,91 +1,115 @@ - -// **************************************************************** -// Copyright (c) 2011 NUnit Software. All rights reserved. -// **************************************************************** -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestPlatform.ObjectModel; -using NUnit.Framework; - - -namespace NUnit.VisualStudio.TestAdapter.Tests -{ - using System.Reflection; - - using NUnit.Core; - using NUnit.Core.Filters; - - [TestFixture] - public class AssemblyRunnerTests - { - private readonly static Uri EXECUTOR_URI = new Uri(NUnitTestExecutor.ExecutorUri); - - private void FakeTestMethod1() - { - } - - private void FakeTestMethod2() - { - } - - private ITest fakeTest1; - - private ITest fakeTest2; - - [SetUp] - public void SetUp() - { - MethodInfo fakeTestMethod1 = this.GetType().GetMethod("FakeTestMethod1", BindingFlags.Instance | BindingFlags.NonPublic); - this.fakeTest1 = new NUnitTestMethod(fakeTestMethod1); - MethodInfo fakeTestMethod2 = this.GetType().GetMethod("FakeTestMethod2", BindingFlags.Instance | BindingFlags.NonPublic); - this.fakeTest2 = new NUnitTestMethod(fakeTestMethod2); - } - - - - [Test] - public void VerifyConstruction1() - { - var runner = new AssemblyRunner(new TestLogger(), "test"); - Assert.That(runner.NUnitFilter.IsEmpty, Is.True); - } - - [Test] - public void VerifyConstruction2() - { - var t1 = new TestCase(fakeTest1.TestName.FullName, EXECUTOR_URI, "test"); - var t2 = new TestCase(fakeTest2.TestName.FullName, EXECUTOR_URI, "test"); - var list = new List { t1, t2 }; - var runner = new AssemblyRunner(new TestLogger(), "test", list); - Assert.False(runner.NUnitFilter.IsEmpty); - Assert.That(runner.NUnitFilter, Is.TypeOf()); - Assert.True(runner.NUnitFilter.Match(fakeTest1)); - Assert.True(runner.NUnitFilter.Match(fakeTest2)); - } - - // TODO: Instead of using AddTestCases, we should be loading an actual assembly - - [Test] - public void AddsNonFilteredCorrectly() - { - var runner = new AssemblyRunner(new TestLogger(), "test"); - runner.AddTestCases(fakeTest1); - runner.AddTestCases(fakeTest2); - Assert.That(runner.NUnitFilter.IsEmpty,Is.True,"NUnitfilter has been touched"); - Assert.That(runner.LoadedTestCases.Count,Is.EqualTo(2),"We should have had 2 test cases here"); - } - - [Test] - public void AddsFilteredCorrectly() - { - var t1 = new TestCase(fakeTest1.TestName.FullName, EXECUTOR_URI, "test"); - var t2 = new TestCase(fakeTest2.TestName.FullName, EXECUTOR_URI, "test"); - var list = new List { t1, t2 }; - var runner = new AssemblyRunner(new TestLogger(), "test",list); - 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"); - } - } -} + +// **************************************************************** +// Copyright (c) 2011 NUnit Software. All rights reserved. +// **************************************************************** +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Moq; +using NUnit.Framework; + + +namespace NUnit.VisualStudio.TestAdapter.Tests +{ + using System.Reflection; + + using NUnit.Core; + using NUnit.Core.Filters; + + [TestFixture] + public class AssemblyRunnerTests + { + private readonly static Uri EXECUTOR_URI = new Uri(NUnitTestExecutor.ExecutorUri); + + private void FakeTestMethod1() + { + } + + private void FakeTestMethod2() + { + } + + private ITest fakeTest1; + + private ITest fakeTest2; + + [SetUp] + public void SetUp() + { + MethodInfo fakeTestMethod1 = this.GetType().GetMethod("FakeTestMethod1", BindingFlags.Instance | BindingFlags.NonPublic); + this.fakeTest1 = new NUnitTestMethod(fakeTestMethod1); + MethodInfo fakeTestMethod2 = this.GetType().GetMethod("FakeTestMethod2", BindingFlags.Instance | BindingFlags.NonPublic); + this.fakeTest2 = new NUnitTestMethod(fakeTestMethod2); + } + + + + [Test] + public void VerifyConstruction1() + { + var runner = new AssemblyRunner(new TestLogger(), "test"); + Assert.That(runner.NUnitFilter.IsEmpty, Is.True); + } + + [Test] + public void VerifyConstruction2() + { + var t1 = new TestCase(fakeTest1.TestName.FullName, EXECUTOR_URI, "test"); + var t2 = new TestCase(fakeTest2.TestName.FullName, EXECUTOR_URI, "test"); + var list = new List { t1, t2 }; + var runner = new AssemblyRunner(new TestLogger(), "test", list); + Assert.False(runner.NUnitFilter.IsEmpty); + Assert.That(runner.NUnitFilter, Is.TypeOf()); + Assert.True(runner.NUnitFilter.Match(fakeTest1)); + Assert.True(runner.NUnitFilter.Match(fakeTest2)); + } + + // TODO: Instead of using AddTestCases, we should be loading an actual assembly + + [Test] + public void AddsNonFilteredCorrectly() + { + var runner = new AssemblyRunner(new TestLogger(), "test"); + runner.AddTestCases(fakeTest1); + runner.AddTestCases(fakeTest2); + Assert.That(runner.NUnitFilter.IsEmpty,Is.True,"NUnitfilter has been touched"); + Assert.That(runner.LoadedTestCases.Count,Is.EqualTo(2),"We should have had 2 test cases here"); + } + + [Test] + public void AddsFilteredCorrectly() + { + var t1 = new TestCase(fakeTest1.TestName.FullName, EXECUTOR_URI, "test"); + var t2 = new TestCase(fakeTest2.TestName.FullName, EXECUTOR_URI, "test"); + var list = new List { t1, t2 }; + var runner = new AssemblyRunner(new TestLogger(), "test",list); + 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 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 16d5999..99bdc56 100644 --- a/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj +++ b/src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj @@ -1,101 +1,110 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {D261700A-5950-46AB-BA3A-304ADBED0DE6} - Library - Properties - NUnit.VisualStudio.TestAdapter.Tests - NUnit.VisualStudio.TestAdapter.Tests - v4.5 - 512 - - ..\..\ - true - - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - $(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - False - ..\..\lib\mock-assembly.dll - - - False - ..\..\lib\nunit.core.dll - - - False - ..\..\lib\nunit.core.interfaces.dll - - - False - ..\..\packages\NUnitTestAdapter.WithFramework.0.95.0\lib\nunit.framework.dll - - - False - ..\..\lib\nunit.util.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - {8a85e26a-c706-48b1-bc36-06ebde3efd25} - NUnitTestAdapter - - - - + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {D261700A-5950-46AB-BA3A-304ADBED0DE6} + Library + Properties + NUnit.VisualStudio.TestAdapter.Tests + NUnit.VisualStudio.TestAdapter.Tests + v4.5 + 512 + + ..\..\ + true + + + true + full + false + bin\Debug\ + TRACE;DEBUG + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + $(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + + + False + ..\..\lib\mock-assembly.dll + + + ..\..\packages\Moq.4.1.1309.1617\lib\net40\Moq.dll + + + False + ..\..\lib\nunit.core.dll + + + False + ..\..\lib\nunit.core.interfaces.dll + + + False + ..\..\packages\NUnitTestAdapter.WithFramework.0.95.0\lib\nunit.framework.dll + + + False + ..\..\lib\nunit.util.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + {8a85e26a-c706-48b1-bc36-06ebde3efd25} + NUnitTestAdapter + + + + + + + + + + + --> \ No newline at end of file diff --git a/src/NUnitTestAdapterTests/packages.config b/src/NUnitTestAdapterTests/packages.config new file mode 100644 index 0000000..a9c8a3f --- /dev/null +++ b/src/NUnitTestAdapterTests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 1210b0128dbe0ae1d228fb303778d951acb52159 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 3 Nov 2013 22:33:56 +0100 Subject: [PATCH 4/5] Updated gitignore to ignore packages folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c50b4d4..6c4f74a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ TestResults *.mdf /Backup /UpgradeLog.htm +packages/ From ffbfcb6d941bff491b14334b829b97d55c92a6c6 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Mon, 4 Nov 2013 21:48:51 +0100 Subject: [PATCH 5/5] Updated --- src/NUnitTestAdapter/AssemblyRunner.cs | 2 +- src/NUnitTestAdapter/Properties/AssemblyInfo.cs | 4 ++-- src/NUnitTestAdapterInstall/source.extension.vsixmanifest | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NUnitTestAdapter/AssemblyRunner.cs b/src/NUnitTestAdapter/AssemblyRunner.cs index 419ffc4..5af57a9 100644 --- a/src/NUnitTestAdapter/AssemblyRunner.cs +++ b/src/NUnitTestAdapter/AssemblyRunner.cs @@ -99,7 +99,7 @@ namespace NUnit.VisualStudio.TestAdapter try { #if LAUNCHDEBUGGER - Debugger.Launch(); + System.Diagnostics.Debugger.Launch(); #endif if (TryLoadAssembly()) { diff --git a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs index 915f1a6..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.5")] -[assembly: AssemblyFileVersion("1.0.0.5")] +[assembly: AssemblyVersion("1.0.0.7")] +[assembly: AssemblyFileVersion("1.0.0.7")] diff --git a/src/NUnitTestAdapterInstall/source.extension.vsixmanifest b/src/NUnitTestAdapterInstall/source.extension.vsixmanifest index dd81ca1..ff6462e 100644 --- a/src/NUnitTestAdapterInstall/source.extension.vsixmanifest +++ b/src/NUnitTestAdapterInstall/source.extension.vsixmanifest @@ -3,7 +3,7 @@ NUnit Test Adapter Charlie Poole - 1.0.0.5 + 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