diff --git a/src/extension/nunit.v2.driver.csproj b/src/extension/nunit.v2.driver.csproj index 459f3e1..c182d98 100644 --- a/src/extension/nunit.v2.driver.csproj +++ b/src/extension/nunit.v2.driver.csproj @@ -16,7 +16,7 @@ true full false - ..\..\..\..\bin\Debug\addins\ + ..\..\bin\Debug\ DEBUG;TRACE prompt 4 @@ -25,7 +25,7 @@ pdbonly true - ..\..\..\..\bin\Release\addins\ + ..\..\bin\Release\ TRACE prompt 4 diff --git a/src/nunit.v2.driver.tests/NUnit2FrameworkDriverTests.cs b/src/nunit.v2.driver.tests/NUnit2FrameworkDriverTests.cs new file mode 100644 index 0000000..6b891d8 --- /dev/null +++ b/src/nunit.v2.driver.tests/NUnit2FrameworkDriverTests.cs @@ -0,0 +1,106 @@ +// *********************************************************************** +// Copyright (c) 2016 Charlie Poole +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// *********************************************************************** + +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using NUnit.Framework; + +namespace NUnit.Engine.Drivers.Tests +{ + public class NUnit2FrameworkDriverTests + { + private const string ASSEMBLY_NAME = "v2-test-assembly.dll"; + private const string V2_TEST_DIR = "v2-tests"; + private const string V2_DOMAIN_NAME = "v2_test_domain"; + private const string EMPTY_FILTER = ""; + private const int TESTCASECOUNT = 74; + + private static readonly string V2_TEST_PATH = Path.GetFullPath(V2_TEST_DIR); + private static readonly string ASSEMBLY_PATH = Path.Combine(V2_TEST_PATH, ASSEMBLY_NAME); + + private NUnit2FrameworkDriver _driver; + + [OneTimeSetUp] + public void CreateDriver() + { + var domain = AppDomain.CreateDomain(V2_DOMAIN_NAME, null, V2_TEST_PATH, null, false); + _driver = new NUnit2FrameworkDriver(domain); + + var settings = new Dictionary(); + + PerformBasicResultChecks(_driver.Load(ASSEMBLY_PATH, settings)); + } + + [Test] + public void Explore() + { + PerformBasicResultChecks(_driver.Explore(EMPTY_FILTER)); + } + + [Test] + public void CountTestCases() + { + Assert.That(_driver.CountTestCases(EMPTY_FILTER), Is.EqualTo(TESTCASECOUNT)); + } + + [Test] + public void Run() + { + XmlNode result = GetResult(_driver.Run(null, EMPTY_FILTER)); + PerformBasicResultChecks(result); + Assert.That(result.SelectNodes("//test-case").Count, Is.EqualTo(TESTCASECOUNT)); + } + + private XmlNode GetResult(string xml) + { + var doc = new XmlDocument(); + doc.LoadXml(xml); + return doc.FirstChild; + } + + private string GetAttribute(XmlNode node, string name) + { + var attr = node.Attributes[name]; + return attr != null + ? attr.Value + : null; + } + + private void PerformBasicResultChecks(string xml) + { + PerformBasicResultChecks(GetResult(xml)); + } + + private void PerformBasicResultChecks(XmlNode result) + { + Assert.That(result.Name, Is.EqualTo("test-suite")); + Assert.That(GetAttribute(result, "type"), Is.EqualTo("Assembly")); + Assert.That(GetAttribute(result, "id"), Does.StartWith("1-")); + Assert.That(GetAttribute(result, "name"), Is.EqualTo(ASSEMBLY_PATH)); + Assert.That(GetAttribute(result, "runstate"), Is.EqualTo("Runnable")); + Assert.That(GetAttribute(result, "testcasecount"), Is.EqualTo(TESTCASECOUNT.ToString())); + } + } +} diff --git a/src/nunit.v2.driver.tests/TestEventAdapterTests.cs b/src/nunit.v2.driver.tests/TestEventAdapterTests.cs index 3f2a33b..d553626 100644 --- a/src/nunit.v2.driver.tests/TestEventAdapterTests.cs +++ b/src/nunit.v2.driver.tests/TestEventAdapterTests.cs @@ -1,4 +1,27 @@ -using System; +// *********************************************************************** +// Copyright (c) 2016 Charlie Poole +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// *********************************************************************** + +using System; using System.Reflection; using NUnit.Core; using NUnit.Framework; diff --git a/src/nunit.v2.driver.tests/nunit.v2.driver.tests.csproj b/src/nunit.v2.driver.tests/nunit.v2.driver.tests.csproj index 21519ce..a2607d8 100644 --- a/src/nunit.v2.driver.tests/nunit.v2.driver.tests.csproj +++ b/src/nunit.v2.driver.tests/nunit.v2.driver.tests.csproj @@ -16,7 +16,7 @@ true full false - bin\Debug\ + ..\..\bin\Debug\ DEBUG;TRACE prompt 4 @@ -24,7 +24,7 @@ pdbonly true - bin\Release\ + ..\..\bin\Release\ TRACE prompt 4 @@ -54,6 +54,7 @@ + diff --git a/src/v2-test-assembly/v2-test-assembly.csproj b/src/v2-test-assembly/v2-test-assembly.csproj index c12ff06..4d688a9 100644 --- a/src/v2-test-assembly/v2-test-assembly.csproj +++ b/src/v2-test-assembly/v2-test-assembly.csproj @@ -8,7 +8,7 @@ Library Properties NUnit.Engine.Drivers.Tests - v2.test.assembly + v2-test-assembly v2.0 512 @@ -16,7 +16,7 @@ true full false - ..\..\bin\Debug\ + ..\..\bin\Debug\v2-tests\ DEBUG;TRACE prompt 4 @@ -25,7 +25,7 @@ pdbonly true - ..\..\bin\Release\ + ..\..\bin\Release\v2-tests\ TRACE prompt 4