Add tests
This commit is contained in:
Родитель
87f4da5d36
Коммит
65ffce1e34
|
@ -16,7 +16,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\bin\Debug\addins\</OutputPath>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\..\bin\Release\addins\</OutputPath>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
|
@ -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 = "<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<string, object>();
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -54,6 +54,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NUnit2FrameworkDriverTests.cs" />
|
||||
<Compile Include="TestEventAdapterTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.Engine.Drivers.Tests</RootNamespace>
|
||||
<AssemblyName>v2.test.assembly</AssemblyName>
|
||||
<AssemblyName>v2-test-assembly</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<OutputPath>..\..\bin\Debug\v2-tests\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<OutputPath>..\..\bin\Release\v2-tests\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
Загрузка…
Ссылка в новой задаче