Updated libs to 2-6-3, and VS 2013
This commit is contained in:
Родитель
152ab8f069
Коммит
d0c1f6dc6e
Двоичные данные
lib/mock-assembly.dll
Двоичные данные
lib/mock-assembly.dll
Двоичный файл не отображается.
Двоичные данные
lib/nunit.core.dll
Двоичные данные
lib/nunit.core.dll
Двоичный файл не отображается.
Двоичные данные
lib/nunit.core.interfaces.dll
Двоичные данные
lib/nunit.core.interfaces.dll
Двоичный файл не отображается.
Двоичные данные
lib/nunit.framework.dll
Двоичные данные
lib/nunit.framework.dll
Двоичный файл не отображается.
Двоичные данные
lib/nunit.util.dll
Двоичные данные
lib/nunit.util.dll
Двоичный файл не отображается.
|
@ -1,54 +1,54 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
public class AsyncMethodHelper : MarshalByRefObject
|
||||
{
|
||||
Assembly targetAssembly;
|
||||
|
||||
public void LoadAssembly(string assemblyName)
|
||||
{
|
||||
targetAssembly = Assembly.LoadFrom(assemblyName);
|
||||
}
|
||||
|
||||
public string GetClassNameForAsyncMethod(string className, string methodName)
|
||||
{
|
||||
if (targetAssembly == null) return null;
|
||||
|
||||
var definingType = targetAssembly.GetType(className);
|
||||
if (definingType == null) return null;
|
||||
|
||||
var method = definingType.GetMethod(methodName);
|
||||
if (method == null) return null;
|
||||
|
||||
var asyncAttribute = GetAsyncStateMachineAttribute(method);
|
||||
if (asyncAttribute == null) return null;
|
||||
|
||||
PropertyInfo stateMachineTypeProperty = asyncAttribute.GetType().GetProperty("StateMachineType");
|
||||
if (stateMachineTypeProperty == null) return null;
|
||||
|
||||
Type asyncStateMachineType = stateMachineTypeProperty.GetValue(asyncAttribute, new object[0]) as Type;
|
||||
if (asyncStateMachineType == null) return null;
|
||||
|
||||
return asyncStateMachineType.FullName;
|
||||
}
|
||||
|
||||
private Attribute GetAsyncStateMachineAttribute(MethodInfo method)
|
||||
{
|
||||
foreach (Attribute attribute in method.GetCustomAttributes(false) )
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
public class AsyncMethodHelper : MarshalByRefObject
|
||||
{
|
||||
Assembly targetAssembly;
|
||||
|
||||
public void LoadAssembly(string assemblyName)
|
||||
{
|
||||
targetAssembly = Assembly.LoadFrom(assemblyName);
|
||||
}
|
||||
|
||||
public string GetClassNameForAsyncMethod(string className, string methodName)
|
||||
{
|
||||
if (targetAssembly == null) return null;
|
||||
|
||||
var definingType = targetAssembly.GetType(className);
|
||||
if (definingType == null) return null;
|
||||
|
||||
var method = definingType.GetMethod(methodName);
|
||||
if (method == null) return null;
|
||||
|
||||
var asyncAttribute = GetAsyncStateMachineAttribute(method);
|
||||
if (asyncAttribute == null) return null;
|
||||
|
||||
PropertyInfo stateMachineTypeProperty = asyncAttribute.GetType().GetProperty("StateMachineType");
|
||||
if (stateMachineTypeProperty == null) return null;
|
||||
|
||||
Type asyncStateMachineType = stateMachineTypeProperty.GetValue(asyncAttribute, new object[0]) as Type;
|
||||
if (asyncStateMachineType == null) return null;
|
||||
|
||||
return asyncStateMachineType.FullName;
|
||||
}
|
||||
|
||||
private Attribute GetAsyncStateMachineAttribute(MethodInfo method)
|
||||
{
|
||||
foreach (Attribute attribute in method.GetCustomAttributes(false) )
|
||||
if (attribute.GetType().FullName == "System.Runtime.CompilerServices.AsyncStateMachineAttribute")
|
||||
return attribute;
|
||||
return null;
|
||||
}
|
||||
|
||||
public override object InitializeLifetimeService()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override object InitializeLifetimeService()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System.Reflection;
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using NUnit.Util;
|
||||
|
||||
using NUnit.Util;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// NUnitTestAdapter is the common base for the
|
||||
/// NUnit discoverer and executor classes.
|
||||
/// </summary>
|
||||
public abstract class NUnitTestAdapter
|
||||
{
|
||||
// Our logger used to display messages
|
||||
protected TestLogger testLog = new TestLogger();
|
||||
|
||||
// The adapter version
|
||||
private string adapterVersion;
|
||||
|
||||
#region Constructor
|
||||
|
||||
public abstract class NUnitTestAdapter
|
||||
{
|
||||
// Our logger used to display messages
|
||||
protected TestLogger testLog = new TestLogger();
|
||||
|
||||
// The adapter version
|
||||
private string adapterVersion;
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// The common constructor initializes NUnit services
|
||||
/// needed to load and run tests and sets some properties.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
protected NUnitTestAdapter()
|
||||
{
|
||||
ServiceManager.Services.AddService(new DomainManager());
|
||||
ServiceManager.Services.AddService(new ProjectService());
|
||||
|
||||
ServiceManager.Services.InitializeServices();
|
||||
|
||||
adapterVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
ServiceManager.Services.InitializeServices();
|
||||
|
||||
adapterVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Helper Methods
|
||||
|
||||
protected void Info(string method, string function)
|
||||
{
|
||||
var msg = string.Format("NUnit {0} {1} is {2}", adapterVersion, method, function);
|
||||
testLog.SendInformationalMessage(msg);
|
||||
protected void Info(string method, string function)
|
||||
{
|
||||
var msg = string.Format("NUnit {0} {1} is {2}", adapterVersion, method, function);
|
||||
testLog.SendInformationalMessage(msg);
|
||||
}
|
||||
|
||||
protected static void CleanUpRegisteredChannels()
|
||||
|
@ -52,6 +52,6 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
ChannelServices.UnregisterChannel(chan);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,108 +1,107 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
|
||||
<AssemblyName>NUnit.VisualStudio.TestAdapter</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<CodeAnalysisRuleSet>..\..\Osiris.Extended.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>NUnitAdapter.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
|
||||
<HintPath>$(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.util, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.util.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyRunner.cs" />
|
||||
<Compile Include="Internal\AsyncMethodHelper.cs" />
|
||||
<Compile Include="Internal\Stackframe.cs" />
|
||||
<Compile Include="Internal\StackframeParser.cs" />
|
||||
<Compile Include="Internal\Stacktrace.cs" />
|
||||
<Compile Include="NUnitEventListener.cs" />
|
||||
<Compile Include="NUnitTestAdapter.cs" />
|
||||
<Compile Include="NUnitTestDiscoverer.cs" />
|
||||
<Compile Include="NUnitTestExecutor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StackTraceFilter.cs" />
|
||||
<Compile Include="TestConverter.cs" />
|
||||
<Compile Include="TestLogger.cs" />
|
||||
<Compile Include="TestRunFilter.cs" />
|
||||
<Compile Include="TFSTestFilter.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TraitsFeature.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="NUnitAdapter.snk" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
|
||||
<AssemblyName>NUnit.VisualStudio.TestAdapter</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<CodeAnalysisRuleSet>..\..\Osiris.Extended.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>NUnitAdapter.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.util, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.util.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyRunner.cs" />
|
||||
<Compile Include="Internal\AsyncMethodHelper.cs" />
|
||||
<Compile Include="Internal\Stackframe.cs" />
|
||||
<Compile Include="Internal\StackframeParser.cs" />
|
||||
<Compile Include="Internal\Stacktrace.cs" />
|
||||
<Compile Include="NUnitEventListener.cs" />
|
||||
<Compile Include="NUnitTestAdapter.cs" />
|
||||
<Compile Include="NUnitTestDiscoverer.cs" />
|
||||
<Compile Include="NUnitTestExecutor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StackTraceFilter.cs" />
|
||||
<Compile Include="TestConverter.cs" />
|
||||
<Compile Include="TestLogger.cs" />
|
||||
<Compile Include="TestRunFilter.cs" />
|
||||
<Compile Include="TFSTestFilter.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TraitsFeature.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="NUnitAdapter.snk" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
-->
|
||||
</Project>
|
|
@ -1,113 +1,113 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
using NUnit.Core;
|
||||
using NUnit.Util;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
using System;
|
||||
|
||||
[FileExtension(".dll")]
|
||||
[FileExtension(".exe")]
|
||||
[DefaultExecutorUri(NUnitTestExecutor.ExecutorUri)]
|
||||
public sealed class NUnitTestDiscoverer : NUnitTestAdapter, ITestDiscoverer
|
||||
{
|
||||
|
||||
#region ITestDiscoverer Members
|
||||
|
||||
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink)
|
||||
{
|
||||
testLog.Initialize(messageLogger);
|
||||
Info("discovering tests", "started");
|
||||
|
||||
// Ensure any channels registered by other adapters are unregistered
|
||||
CleanUpRegisteredChannels();
|
||||
|
||||
foreach (string sourceAssembly in sources)
|
||||
{
|
||||
testLog.SendDebugMessage("Processing " + sourceAssembly);
|
||||
|
||||
TestRunner runner = new TestDomain();
|
||||
TestPackage package = new TestPackage(sourceAssembly);
|
||||
TestConverter testConverter = null;
|
||||
try
|
||||
{
|
||||
if (runner.Load(package))
|
||||
{
|
||||
testConverter = new TestConverter(testLog, sourceAssembly);
|
||||
int cases = ProcessTestCases(runner.Test, discoverySink, testConverter);
|
||||
testLog.SendDebugMessage(string.Format("Discovered {0} test cases", cases));
|
||||
}
|
||||
else
|
||||
{
|
||||
testLog.NUnitLoadError(sourceAssembly);
|
||||
}
|
||||
}
|
||||
catch (System.BadImageFormatException)
|
||||
{
|
||||
// we skip the native c++ binaries that we don't support.
|
||||
testLog.AssemblyNotSupportedWarning(sourceAssembly);
|
||||
}
|
||||
|
||||
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
|
||||
testLog.DependentAssemblyNotFoundWarning(ex.FileName, sourceAssembly);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception thrown discovering tests in " + sourceAssembly, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (testConverter != null)
|
||||
testConverter.Dispose();
|
||||
testConverter = null;
|
||||
runner.Unload();
|
||||
}
|
||||
}
|
||||
|
||||
Info("discovering test", "finished");
|
||||
}
|
||||
|
||||
private int ProcessTestCases(ITest test, ITestCaseDiscoverySink discoverySink, TestConverter testConverter)
|
||||
{
|
||||
int cases = 0;
|
||||
|
||||
if (test.IsSuite)
|
||||
{
|
||||
foreach (ITest child in test.Tests)
|
||||
cases += ProcessTestCases(child, discoverySink,testConverter);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
#if LAUNCHDEBUGGER
|
||||
Debugger.Launch();
|
||||
#endif
|
||||
TestCase testCase = testConverter.ConvertTestCase(test);
|
||||
|
||||
discoverySink.SendTestCase(testCase);
|
||||
cases += 1;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception converting " + test.TestName.FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return cases;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
using NUnit.Core;
|
||||
using NUnit.Util;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
using System;
|
||||
|
||||
[FileExtension(".dll")]
|
||||
[FileExtension(".exe")]
|
||||
[DefaultExecutorUri(NUnitTestExecutor.ExecutorUri)]
|
||||
public sealed class NUnitTestDiscoverer : NUnitTestAdapter, ITestDiscoverer
|
||||
{
|
||||
|
||||
#region ITestDiscoverer Members
|
||||
|
||||
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink)
|
||||
{
|
||||
testLog.Initialize(messageLogger);
|
||||
Info("discovering tests", "started");
|
||||
|
||||
// Ensure any channels registered by other adapters are unregistered
|
||||
CleanUpRegisteredChannels();
|
||||
|
||||
foreach (string sourceAssembly in sources)
|
||||
{
|
||||
testLog.SendDebugMessage("Processing " + sourceAssembly);
|
||||
|
||||
TestRunner runner = new TestDomain();
|
||||
TestPackage package = new TestPackage(sourceAssembly);
|
||||
TestConverter testConverter = null;
|
||||
try
|
||||
{
|
||||
if (runner.Load(package))
|
||||
{
|
||||
testConverter = new TestConverter(testLog, sourceAssembly);
|
||||
int cases = ProcessTestCases(runner.Test, discoverySink, testConverter);
|
||||
testLog.SendDebugMessage(string.Format("Discovered {0} test cases", cases));
|
||||
}
|
||||
else
|
||||
{
|
||||
testLog.NUnitLoadError(sourceAssembly);
|
||||
}
|
||||
}
|
||||
catch (System.BadImageFormatException)
|
||||
{
|
||||
// we skip the native c++ binaries that we don't support.
|
||||
testLog.AssemblyNotSupportedWarning(sourceAssembly);
|
||||
}
|
||||
|
||||
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
|
||||
testLog.DependentAssemblyNotFoundWarning(ex.FileName, sourceAssembly);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception thrown discovering tests in " + sourceAssembly, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (testConverter != null)
|
||||
testConverter.Dispose();
|
||||
testConverter = null;
|
||||
runner.Unload();
|
||||
}
|
||||
}
|
||||
|
||||
Info("discovering test", "finished");
|
||||
}
|
||||
|
||||
private int ProcessTestCases(ITest test, ITestCaseDiscoverySink discoverySink, TestConverter testConverter)
|
||||
{
|
||||
int cases = 0;
|
||||
|
||||
if (test.IsSuite)
|
||||
{
|
||||
foreach (ITest child in test.Tests)
|
||||
cases += ProcessTestCases(child, discoverySink,testConverter);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
#if LAUNCHDEBUGGER
|
||||
Debugger.Launch();
|
||||
#endif
|
||||
TestCase testCase = testConverter.ConvertTestCase(test);
|
||||
|
||||
discoverySink.SendTestCase(testCase);
|
||||
cases += 1;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception converting " + test.TestName.FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return cases;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,133 +1,133 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
using NUnit.Core;
|
||||
// #define LAUNCHDEBUGGER
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
|
||||
[ExtensionUri(NUnitTestExecutor.ExecutorUri)]
|
||||
public sealed class NUnitTestExecutor : NUnitTestAdapter, ITestExecutor, IDisposable
|
||||
{
|
||||
///<summary>
|
||||
/// The Uri used to identify the NUnitExecutor
|
||||
///</summary>
|
||||
public const string ExecutorUri = "executor://NUnitTestExecutor";
|
||||
|
||||
// The currently executing assembly runner
|
||||
private AssemblyRunner currentRunner;
|
||||
|
||||
#region ITestExecutor
|
||||
|
||||
/// <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);
|
||||
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);
|
||||
if (!tfsfilter.HasTfsFilterValue && runContext.KeepAlive)
|
||||
frameworkHandle.EnableShutdownAfterTestRun = true;
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
using (currentRunner = new AssemblyRunner(testLog, source, tfsfilter))
|
||||
{
|
||||
currentRunner.RunAssembly(frameworkHandle);
|
||||
}
|
||||
|
||||
currentRunner = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception " + ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Info("executing tests", "finished");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the VisualStudio IDE when selected tests are to be run. Never called from TFS Build.
|
||||
/// </summary>
|
||||
/// <param name="tests">The tests to be run</param>
|
||||
/// <param name="runContext">The RunContext</param>
|
||||
/// <param name="frameworkHandle">The FrameworkHandle</param>
|
||||
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
|
||||
{
|
||||
#if LAUNCHDEBUGGER
|
||||
Debugger.Launch();
|
||||
#endif
|
||||
|
||||
testLog.Initialize(frameworkHandle);
|
||||
if (runContext.KeepAlive)
|
||||
frameworkHandle.EnableShutdownAfterTestRun = true;
|
||||
Info("executing tests", "started");
|
||||
|
||||
// Ensure any channels registered by other adapters are unregistered
|
||||
CleanUpRegisteredChannels();
|
||||
|
||||
var assemblyGroups = tests.GroupBy(tc => tc.Source);
|
||||
foreach (var assemblyGroup in assemblyGroups)
|
||||
{
|
||||
using (currentRunner = new AssemblyRunner(testLog, assemblyGroup.Key, assemblyGroup))
|
||||
{
|
||||
currentRunner.RunAssembly(frameworkHandle);
|
||||
}
|
||||
|
||||
currentRunner = null;
|
||||
}
|
||||
|
||||
Info("executing tests", "finished");
|
||||
|
||||
}
|
||||
|
||||
void ITestExecutor.Cancel()
|
||||
{
|
||||
if (currentRunner != null)
|
||||
currentRunner.CancelRun();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (currentRunner != null)
|
||||
{
|
||||
currentRunner.Dispose();
|
||||
}
|
||||
}
|
||||
currentRunner = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
using NUnit.Core;
|
||||
// #define LAUNCHDEBUGGER
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
|
||||
[ExtensionUri(NUnitTestExecutor.ExecutorUri)]
|
||||
public sealed class NUnitTestExecutor : NUnitTestAdapter, ITestExecutor, IDisposable
|
||||
{
|
||||
///<summary>
|
||||
/// The Uri used to identify the NUnitExecutor
|
||||
///</summary>
|
||||
public const string ExecutorUri = "executor://NUnitTestExecutor";
|
||||
|
||||
// The currently executing assembly runner
|
||||
private AssemblyRunner currentRunner;
|
||||
|
||||
#region ITestExecutor
|
||||
|
||||
/// <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);
|
||||
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);
|
||||
if (!tfsfilter.HasTfsFilterValue && runContext.KeepAlive)
|
||||
frameworkHandle.EnableShutdownAfterTestRun = true;
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
using (currentRunner = new AssemblyRunner(testLog, source, tfsfilter))
|
||||
{
|
||||
currentRunner.RunAssembly(frameworkHandle);
|
||||
}
|
||||
|
||||
currentRunner = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
testLog.SendErrorMessage("Exception " + ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Info("executing tests", "finished");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the VisualStudio IDE when selected tests are to be run. Never called from TFS Build.
|
||||
/// </summary>
|
||||
/// <param name="tests">The tests to be run</param>
|
||||
/// <param name="runContext">The RunContext</param>
|
||||
/// <param name="frameworkHandle">The FrameworkHandle</param>
|
||||
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
|
||||
{
|
||||
#if LAUNCHDEBUGGER
|
||||
Debugger.Launch();
|
||||
#endif
|
||||
|
||||
testLog.Initialize(frameworkHandle);
|
||||
if (runContext.KeepAlive)
|
||||
frameworkHandle.EnableShutdownAfterTestRun = true;
|
||||
Info("executing tests", "started");
|
||||
|
||||
// Ensure any channels registered by other adapters are unregistered
|
||||
CleanUpRegisteredChannels();
|
||||
|
||||
var assemblyGroups = tests.GroupBy(tc => tc.Source);
|
||||
foreach (var assemblyGroup in assemblyGroups)
|
||||
{
|
||||
using (currentRunner = new AssemblyRunner(testLog, assemblyGroup.Key, assemblyGroup))
|
||||
{
|
||||
currentRunner.RunAssembly(frameworkHandle);
|
||||
}
|
||||
|
||||
currentRunner = null;
|
||||
}
|
||||
|
||||
Info("executing tests", "finished");
|
||||
|
||||
}
|
||||
|
||||
void ITestExecutor.Cancel()
|
||||
{
|
||||
if (currentRunner != null)
|
||||
currentRunner.CancelRun();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (currentRunner != null)
|
||||
{
|
||||
currentRunner.Dispose();
|
||||
}
|
||||
}
|
||||
currentRunner = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2011-2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Core;
|
||||
|
||||
using NUnitTestResult = NUnit.Core.TestResult;
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2011-2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Core;
|
||||
|
||||
using NUnitTestResult = NUnit.Core.TestResult;
|
||||
using VSTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
public class TestConverter : IDisposable
|
||||
{
|
||||
{
|
||||
private TestLogger logger;
|
||||
private Dictionary<string, TestCase> vsTestCaseMap;
|
||||
private string sourceAssembly;
|
||||
private AppDomain asyncMethodHelperDomain;
|
||||
|
||||
#region Constructors
|
||||
|
||||
private string sourceAssembly;
|
||||
private AppDomain asyncMethodHelperDomain;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public TestConverter(TestLogger logger, string sourceAssembly)
|
||||
{
|
||||
{
|
||||
this.logger = logger;
|
||||
this.sourceAssembly = sourceAssembly;
|
||||
this.vsTestCaseMap = new Dictionary<string, TestCase>();
|
||||
this.vsTestCaseMap = new Dictionary<string, TestCase>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Converts an NUnit test into a TestCase for Visual Studio,
|
||||
/// using the best method available according to the exact
|
||||
|
@ -53,29 +53,29 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
var testCase = MakeTestCaseFromNUnitTest(test);
|
||||
vsTestCaseMap.Add(test.TestName.UniqueName, testCase);
|
||||
return testCase;
|
||||
}
|
||||
|
||||
public TestCase GetCachedTestCase(string key)
|
||||
{
|
||||
if (vsTestCaseMap.ContainsKey(key))
|
||||
return vsTestCaseMap[key];
|
||||
|
||||
logger.SendErrorMessage("Test " + key + " not found in cache");
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestCase GetCachedTestCase(string key)
|
||||
{
|
||||
if (vsTestCaseMap.ContainsKey(key))
|
||||
return vsTestCaseMap[key];
|
||||
|
||||
logger.SendErrorMessage("Test " + key + " not found in cache");
|
||||
return null;
|
||||
}
|
||||
|
||||
public VSTestResult ConvertTestResult(NUnitTestResult result)
|
||||
{
|
||||
TestCase ourCase = GetCachedTestCase(result.Test.TestName.UniqueName);
|
||||
{
|
||||
TestCase ourCase = GetCachedTestCase(result.Test.TestName.UniqueName);
|
||||
if (ourCase == null) return null;
|
||||
|
||||
VSTestResult ourResult = new VSTestResult(ourCase)
|
||||
{
|
||||
DisplayName = ourCase.DisplayName,
|
||||
Outcome = ResultStateToTestOutcome(result.ResultState),
|
||||
Duration = TimeSpan.FromSeconds(result.Time)
|
||||
};
|
||||
|
||||
VSTestResult ourResult = new VSTestResult(ourCase)
|
||||
{
|
||||
DisplayName = ourCase.DisplayName,
|
||||
Outcome = ResultStateToTestOutcome(result.ResultState),
|
||||
Duration = TimeSpan.FromSeconds(result.Time)
|
||||
};
|
||||
|
||||
// TODO: Remove this when NUnit provides a better duration
|
||||
if (ourResult.Duration == TimeSpan.Zero && (ourResult.Outcome == TestOutcome.Passed || ourResult.Outcome == TestOutcome.Failed))
|
||||
ourResult.Duration = TimeSpan.FromTicks(1);
|
||||
|
@ -99,79 +99,79 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
return ourResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (this.diaSession != null) this.diaSession.Dispose();
|
||||
if (this.asyncMethodHelperDomain != null) AppDomain.Unload(this.asyncMethodHelperDomain);
|
||||
}
|
||||
diaSession = null;
|
||||
asyncMethodHelperDomain = null;
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (this.diaSession != null) this.diaSession.Dispose();
|
||||
if (this.asyncMethodHelperDomain != null) AppDomain.Unload(this.asyncMethodHelperDomain);
|
||||
}
|
||||
diaSession = null;
|
||||
asyncMethodHelperDomain = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
/// <summary>
|
||||
/// Makes a TestCase from an NUnit test, adding
|
||||
/// navigation data if it can be found.
|
||||
/// </summary>
|
||||
private TestCase MakeTestCaseFromNUnitTest(ITest nunitTest)
|
||||
{
|
||||
//var testCase = MakeTestCaseFromTestName(nunitTest.TestName);
|
||||
var testCase = new TestCase(
|
||||
nunitTest.TestName.FullName,
|
||||
new Uri(NUnitTestExecutor.ExecutorUri),
|
||||
this.sourceAssembly)
|
||||
{
|
||||
DisplayName = nunitTest.TestName.Name,
|
||||
CodeFilePath = null,
|
||||
LineNumber = 0
|
||||
};
|
||||
|
||||
var navData = GetNavigationData(nunitTest.ClassName, nunitTest.MethodName);
|
||||
if (navData != null)
|
||||
{
|
||||
testCase.CodeFilePath = navData.FileName;
|
||||
testCase.LineNumber = navData.MinLineNumber;
|
||||
}
|
||||
|
||||
testCase.AddTraitsFromNUnitTest(nunitTest);
|
||||
|
||||
return testCase;
|
||||
}
|
||||
|
||||
// public for testing
|
||||
public DiaNavigationData GetNavigationData(string className, string methodName)
|
||||
{
|
||||
if (this.DiaSession == null) return null;
|
||||
|
||||
var navData = DiaSession.GetNavigationData(className, methodName);
|
||||
|
||||
if (navData != null && navData.FileName != null) return navData;
|
||||
|
||||
// DiaSession returned null, see if it's an async method.
|
||||
if (AsyncMethodHelper != null)
|
||||
{
|
||||
string stateMachineClassName = AsyncMethodHelper.GetClassNameForAsyncMethod(className, methodName);
|
||||
if (stateMachineClassName != null)
|
||||
navData = diaSession.GetNavigationData(stateMachineClassName, "MoveNext");
|
||||
}
|
||||
|
||||
if (navData == null || navData.FileName == null)
|
||||
logger.SendWarningMessage(string.Format("No source data found for {0}.{1}", className, methodName));
|
||||
|
||||
return navData;
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
/// <summary>
|
||||
/// Makes a TestCase from an NUnit test, adding
|
||||
/// navigation data if it can be found.
|
||||
/// </summary>
|
||||
private TestCase MakeTestCaseFromNUnitTest(ITest nunitTest)
|
||||
{
|
||||
//var testCase = MakeTestCaseFromTestName(nunitTest.TestName);
|
||||
var testCase = new TestCase(
|
||||
nunitTest.TestName.FullName,
|
||||
new Uri(NUnitTestExecutor.ExecutorUri),
|
||||
this.sourceAssembly)
|
||||
{
|
||||
DisplayName = nunitTest.TestName.Name,
|
||||
CodeFilePath = null,
|
||||
LineNumber = 0
|
||||
};
|
||||
|
||||
var navData = GetNavigationData(nunitTest.ClassName, nunitTest.MethodName);
|
||||
if (navData != null)
|
||||
{
|
||||
testCase.CodeFilePath = navData.FileName;
|
||||
testCase.LineNumber = navData.MinLineNumber;
|
||||
}
|
||||
|
||||
testCase.AddTraitsFromNUnitTest(nunitTest);
|
||||
|
||||
return testCase;
|
||||
}
|
||||
|
||||
// public for testing
|
||||
public DiaNavigationData GetNavigationData(string className, string methodName)
|
||||
{
|
||||
if (this.DiaSession == null) return null;
|
||||
|
||||
var navData = DiaSession.GetNavigationData(className, methodName);
|
||||
|
||||
if (navData != null && navData.FileName != null) return navData;
|
||||
|
||||
// DiaSession returned null, see if it's an async method.
|
||||
if (AsyncMethodHelper != null)
|
||||
{
|
||||
string stateMachineClassName = AsyncMethodHelper.GetClassNameForAsyncMethod(className, methodName);
|
||||
if (stateMachineClassName != null)
|
||||
navData = diaSession.GetNavigationData(stateMachineClassName, "MoveNext");
|
||||
}
|
||||
|
||||
if (navData == null || navData.FileName == null)
|
||||
logger.SendWarningMessage(string.Format("No source data found for {0}.{1}", className, methodName));
|
||||
|
||||
return navData;
|
||||
}
|
||||
|
||||
// Public for testing
|
||||
public static TestOutcome ResultStateToTestOutcome(ResultState resultState)
|
||||
{
|
||||
|
@ -212,34 +212,34 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private AsyncMethodHelper TryCreateHelper(string sourceAssembly)
|
||||
{
|
||||
var setup = new AppDomainSetup();
|
||||
|
||||
var thisAssembly = Assembly.GetExecutingAssembly();
|
||||
setup.ApplicationBase = AssemblyHelper.GetDirectoryName(thisAssembly);
|
||||
|
||||
var evidence = AppDomain.CurrentDomain.Evidence;
|
||||
this.asyncMethodHelperDomain = AppDomain.CreateDomain("AsyncMethodHelper", evidence, setup);
|
||||
|
||||
try
|
||||
{
|
||||
var helper = this.asyncMethodHelperDomain.CreateInstanceAndUnwrap(
|
||||
thisAssembly.FullName,
|
||||
"NUnit.VisualStudio.TestAdapter.AsyncMethodHelper") as AsyncMethodHelper;
|
||||
helper.LoadAssembly(sourceAssembly);
|
||||
return helper as AsyncMethodHelper;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
// If we can't load it for some reason, we issue a warning
|
||||
// and won't try to do it again for the assembly.
|
||||
logger.SendWarningMessage("Unable to reflect on " + sourceAssembly + "\r\nSource data will not be available for some of the tests");
|
||||
logger.SendWarningMessage(ex.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private AsyncMethodHelper TryCreateHelper(string sourceAssembly)
|
||||
{
|
||||
var setup = new AppDomainSetup();
|
||||
|
||||
var thisAssembly = Assembly.GetExecutingAssembly();
|
||||
setup.ApplicationBase = AssemblyHelper.GetDirectoryName(thisAssembly);
|
||||
|
||||
var evidence = AppDomain.CurrentDomain.Evidence;
|
||||
this.asyncMethodHelperDomain = AppDomain.CreateDomain("AsyncMethodHelper", evidence, setup);
|
||||
|
||||
try
|
||||
{
|
||||
var helper = this.asyncMethodHelperDomain.CreateInstanceAndUnwrap(
|
||||
thisAssembly.FullName,
|
||||
"NUnit.VisualStudio.TestAdapter.AsyncMethodHelper") as AsyncMethodHelper;
|
||||
helper.LoadAssembly(sourceAssembly);
|
||||
return helper as AsyncMethodHelper;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
// If we can't load it for some reason, we issue a warning
|
||||
// and won't try to do it again for the assembly.
|
||||
logger.SendWarningMessage("Unable to reflect on " + sourceAssembly + "\r\nSource data will not be available for some of the tests");
|
||||
logger.SendWarningMessage(ex.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,55 +261,55 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
|
||||
return exeName == "vstest.executionengine.exe";
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: There is some sort of timing issue involved
|
||||
// in creating the DiaSession. When it is created
|
||||
// in the constructor, an exception is thrown on the
|
||||
// call to GetNavigationData. We don't understand
|
||||
// this, we're just dealing with it.
|
||||
private DiaSession diaSession;
|
||||
private bool tryToCreateDiaSession = true;
|
||||
private DiaSession DiaSession
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tryToCreateDiaSession)
|
||||
{
|
||||
try
|
||||
{
|
||||
diaSession = new DiaSession(sourceAssembly);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// If this isn't a project type supporting DiaSession,
|
||||
// we just issue a warning. We won't try this again.
|
||||
logger.SendWarningMessage("Unable to create DiaSession for " + sourceAssembly + "\r\nNo source location data will be available for this assembly.");
|
||||
}
|
||||
|
||||
tryToCreateDiaSession = false;
|
||||
}
|
||||
|
||||
return diaSession;
|
||||
}
|
||||
}
|
||||
|
||||
private AsyncMethodHelper asyncMethodHelper;
|
||||
bool tryToCreateHelper = true;
|
||||
private AsyncMethodHelper AsyncMethodHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tryToCreateHelper)
|
||||
{
|
||||
tryToCreateHelper = false;
|
||||
asyncMethodHelper = TryCreateHelper(sourceAssembly);
|
||||
}
|
||||
|
||||
return asyncMethodHelper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// NOTE: There is some sort of timing issue involved
|
||||
// in creating the DiaSession. When it is created
|
||||
// in the constructor, an exception is thrown on the
|
||||
// call to GetNavigationData. We don't understand
|
||||
// this, we're just dealing with it.
|
||||
private DiaSession diaSession;
|
||||
private bool tryToCreateDiaSession = true;
|
||||
private DiaSession DiaSession
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tryToCreateDiaSession)
|
||||
{
|
||||
try
|
||||
{
|
||||
diaSession = new DiaSession(sourceAssembly);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// If this isn't a project type supporting DiaSession,
|
||||
// we just issue a warning. We won't try this again.
|
||||
logger.SendWarningMessage("Unable to create DiaSession for " + sourceAssembly + "\r\nNo source location data will be available for this assembly.");
|
||||
}
|
||||
|
||||
tryToCreateDiaSession = false;
|
||||
}
|
||||
|
||||
return diaSession;
|
||||
}
|
||||
}
|
||||
|
||||
private AsyncMethodHelper asyncMethodHelper;
|
||||
bool tryToCreateHelper = true;
|
||||
private AsyncMethodHelper AsyncMethodHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tryToCreateHelper)
|
||||
{
|
||||
tryToCreateHelper = false;
|
||||
asyncMethodHelper = TryCreateHelper(sourceAssembly);
|
||||
}
|
||||
|
||||
return asyncMethodHelper;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,81 +1,81 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
/// <summary>
|
||||
/// TestLogger wraps an IMessageLogger and adds various
|
||||
/// utility methods for sending messages. Since the
|
||||
/// IMessageLogger is only provided when the discovery
|
||||
/// and execution objects are called, we use two-phase
|
||||
/// construction. Until Initialize is called, the logger
|
||||
/// simply swallows all messages without sending them
|
||||
/// anywhere.
|
||||
/// </summary>
|
||||
public class TestLogger : IMessageLogger
|
||||
{
|
||||
private IMessageLogger messageLogger;
|
||||
|
||||
public void Initialize(IMessageLogger messageLogger)
|
||||
{
|
||||
this.messageLogger = messageLogger;
|
||||
}
|
||||
|
||||
public void AssemblyNotSupportedWarning(string sourceAssembly)
|
||||
{
|
||||
SendWarningMessage("Assembly not supported: " + sourceAssembly);
|
||||
}
|
||||
|
||||
public void DependentAssemblyNotFoundWarning(string dependentAssembly, string sourceAssembly)
|
||||
{
|
||||
SendWarningMessage("Dependent Assembly " + dependentAssembly + " of " + sourceAssembly + " not found. Can be ignored if not a NUnit project.");
|
||||
}
|
||||
|
||||
public void NUnitLoadError(string sourceAssembly)
|
||||
{
|
||||
SendErrorMessage("NUnit failed to load " + sourceAssembly);
|
||||
}
|
||||
|
||||
public void SendErrorMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Error, message);
|
||||
}
|
||||
|
||||
public void SendErrorMessage(string message, Exception ex)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Error, message);
|
||||
SendMessage(TestMessageLevel.Error, ex.ToString());
|
||||
}
|
||||
|
||||
public void SendWarningMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Warning, message);
|
||||
}
|
||||
|
||||
public void SendInformationalMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Informational, message);
|
||||
}
|
||||
|
||||
public void SendDebugMessage(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
SendMessage(TestMessageLevel.Informational, message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SendMessage(TestMessageLevel testMessageLevel, string message)
|
||||
{
|
||||
if (messageLogger != null)
|
||||
messageLogger.SendMessage(testMessageLevel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
{
|
||||
/// <summary>
|
||||
/// TestLogger wraps an IMessageLogger and adds various
|
||||
/// utility methods for sending messages. Since the
|
||||
/// IMessageLogger is only provided when the discovery
|
||||
/// and execution objects are called, we use two-phase
|
||||
/// construction. Until Initialize is called, the logger
|
||||
/// simply swallows all messages without sending them
|
||||
/// anywhere.
|
||||
/// </summary>
|
||||
public class TestLogger : IMessageLogger
|
||||
{
|
||||
private IMessageLogger messageLogger;
|
||||
|
||||
public void Initialize(IMessageLogger messageLogger)
|
||||
{
|
||||
this.messageLogger = messageLogger;
|
||||
}
|
||||
|
||||
public void AssemblyNotSupportedWarning(string sourceAssembly)
|
||||
{
|
||||
SendWarningMessage("Assembly not supported: " + sourceAssembly);
|
||||
}
|
||||
|
||||
public void DependentAssemblyNotFoundWarning(string dependentAssembly, string sourceAssembly)
|
||||
{
|
||||
SendWarningMessage("Dependent Assembly " + dependentAssembly + " of " + sourceAssembly + " not found. Can be ignored if not a NUnit project.");
|
||||
}
|
||||
|
||||
public void NUnitLoadError(string sourceAssembly)
|
||||
{
|
||||
SendErrorMessage("NUnit failed to load " + sourceAssembly);
|
||||
}
|
||||
|
||||
public void SendErrorMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Error, message);
|
||||
}
|
||||
|
||||
public void SendErrorMessage(string message, Exception ex)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Error, message);
|
||||
SendMessage(TestMessageLevel.Error, ex.ToString());
|
||||
}
|
||||
|
||||
public void SendWarningMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Warning, message);
|
||||
}
|
||||
|
||||
public void SendInformationalMessage(string message)
|
||||
{
|
||||
SendMessage(TestMessageLevel.Informational, message);
|
||||
}
|
||||
|
||||
public void SendDebugMessage(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
SendMessage(TestMessageLevel.Informational, message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SendMessage(TestMessageLevel testMessageLevel, string message)
|
||||
{
|
||||
if (messageLogger != null)
|
||||
messageLogger.SendMessage(testMessageLevel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// ****************************************************************
|
||||
// Copyright (c) 2013 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Core;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter.Tests
|
||||
|
@ -55,13 +56,13 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
await ThrowException();
|
||||
}
|
||||
|
||||
[TestCase(Result = 1)]
|
||||
[TestCase(ExpectedResult = TestOutcome.Passed)]
|
||||
public async Task<int> TaskTTestCaseWithResultCheckSuccess()
|
||||
{
|
||||
return await ReturnOne();
|
||||
}
|
||||
|
||||
[TestCase(Result = 2), ExpectedException(typeof(AssertionException))]
|
||||
[TestCase(ExpectedResult=TestOutcome.Failed), ExpectedException(typeof(AssertionException))]
|
||||
public async Task<int> TaskTTestCaseWithResultCheckFailure()
|
||||
{
|
||||
return await ReturnOne();
|
||||
|
|
|
@ -56,8 +56,8 @@ namespace NUnit.VisualStudio.TestAdapter.Tests.Fakes
|
|||
|
||||
#region IFrameworkHandle Members
|
||||
|
||||
bool IFrameworkHandle.EnableShutdownAfterTestRun
|
||||
{
|
||||
bool IFrameworkHandle.EnableShutdownAfterTestRun
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
|
||||
using NUnit.Core;
|
||||
using NUnit.Framework;
|
||||
using NUnit.VisualStudio.TestAdapter.Tests.Fakes;
|
||||
|
||||
using VSTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult;
|
||||
using NUnit.VisualStudio.TestAdapter.Tests.Fakes;
|
||||
|
||||
using VSTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult;
|
||||
using NUnitTestResult = NUnit.Core.TestResult;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter.Tests
|
||||
|
@ -32,9 +32,9 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
private NUnitTestResult fakeNUnitResult;
|
||||
|
||||
private NUnitEventListener listener;
|
||||
private FakeFrameworkHandle testLog;
|
||||
private TestConverter testConverter;
|
||||
|
||||
private FakeFrameworkHandle testLog;
|
||||
private TestConverter testConverter;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
|
@ -47,9 +47,9 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
|
||||
testLog = new FakeFrameworkHandle();
|
||||
|
||||
testConverter = new TestConverter(new TestLogger(), THIS_ASSEMBLY_PATH);
|
||||
|
||||
testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
testConverter = new TestConverter(new TestLogger(), THIS_ASSEMBLY_PATH);
|
||||
|
||||
testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
Assert.NotNull(testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName));
|
||||
|
||||
this.listener = new NUnitEventListener(testLog, testConverter);
|
||||
|
|
|
@ -36,28 +36,22 @@
|
|||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
|
||||
<HintPath>$(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mock-assembly, Version=2.6.2.12296, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\mock-assembly.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Reference Include="nunit.core">
|
||||
<HintPath>..\..\lib\nunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Reference Include="nunit.core.interfaces">
|
||||
<HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.WithFramework.0.95.0\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.util, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.util.dll</HintPath>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\..\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -83,6 +77,12 @@
|
|||
<Compile Include="TestExecutionTests.cs" />
|
||||
<Compile Include="TestTFSBuild.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NUnitTestAdapter\NUnitTestAdapter.csproj">
|
||||
<Project>{8a85e26a-c706-48b1-bc36-06ebde3efd25}</Project>
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// ****************************************************************
|
||||
// Copyright (c) 2011 NUnit Software. All rights reserved.
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
// ****************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
|
||||
using NUnit.Core;
|
||||
using NUnit.Framework;
|
||||
|
||||
using NUnitTestResult = NUnit.Core.TestResult;
|
||||
using NUnit.Framework;
|
||||
|
||||
using NUnitTestResult = NUnit.Core.TestResult;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter.Tests
|
||||
{
|
||||
|
@ -26,10 +26,10 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
|
||||
// NOTE: If the location of the FakeTestCase method in the
|
||||
// file changes, update the value of FAKE_LINE_NUMBER.
|
||||
private static readonly int FAKE_LINE_NUMBER = 30;
|
||||
private void FakeTestCase() { } // FAKE_LINE_NUMBER SHOULD BE THIS LINE
|
||||
|
||||
private ITest fakeNUnitTest;
|
||||
private static readonly int FAKE_LINE_NUMBER = 30;
|
||||
private void FakeTestCase() { } // FAKE_LINE_NUMBER SHOULD BE THIS LINE
|
||||
|
||||
private ITest fakeNUnitTest;
|
||||
private TestConverter testConverter;
|
||||
|
||||
[SetUp]
|
||||
|
@ -47,15 +47,15 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
Assert.That(nunitTest.Parent, Is.SameAs(nunitFixture));
|
||||
|
||||
var fixtureNode = new TestNode(nunitFixture);
|
||||
fakeNUnitTest = (ITest)fixtureNode.Tests[0];
|
||||
|
||||
fakeNUnitTest = (ITest)fixtureNode.Tests[0];
|
||||
|
||||
testConverter = new TestConverter(new TestLogger(), THIS_ASSEMBLY_PATH);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
testConverter.Dispose();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
testConverter.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -64,44 +64,44 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
var testCase = testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
|
||||
CheckTestCase(testCase);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertedTestCaseIsCached()
|
||||
{
|
||||
testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
var testCase = testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName);
|
||||
|
||||
CheckTestCase(testCase);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CannotMakeTestResultWhenTestCaseIsNotInCache()
|
||||
{
|
||||
var nunitResult = new NUnitTestResult(fakeNUnitTest);
|
||||
var testResult = testConverter.ConvertTestResult(nunitResult);
|
||||
Assert.Null(testResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertedTestCaseIsCached()
|
||||
{
|
||||
testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
var testCase = testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName);
|
||||
|
||||
CheckTestCase(testCase);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CannotMakeTestResultWhenTestCaseIsNotInCache()
|
||||
{
|
||||
var nunitResult = new NUnitTestResult(fakeNUnitTest);
|
||||
var testResult = testConverter.ConvertTestResult(nunitResult);
|
||||
Assert.Null(testResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanMakeTestResultFromNUnitTestResult()
|
||||
{
|
||||
// This should put the TestCase in the cache
|
||||
var cachedTestCase = testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
|
||||
var nunitResult = new NUnitTestResult(fakeNUnitTest);
|
||||
nunitResult.SetResult(ResultState.Success, "It passed!", null);
|
||||
nunitResult.Time = 1.234;
|
||||
{
|
||||
// This should put the TestCase in the cache
|
||||
var cachedTestCase = testConverter.ConvertTestCase(fakeNUnitTest);
|
||||
|
||||
var nunitResult = new NUnitTestResult(fakeNUnitTest);
|
||||
nunitResult.SetResult(ResultState.Success, "It passed!", null);
|
||||
nunitResult.Time = 1.234;
|
||||
|
||||
var testResult = testConverter.ConvertTestResult(nunitResult);
|
||||
var testCase = testResult.TestCase;
|
||||
|
||||
var testCase = testResult.TestCase;
|
||||
|
||||
Assert.That(testCase, Is.SameAs(cachedTestCase));
|
||||
|
||||
CheckTestCase(testCase);
|
||||
|
||||
Assert.That(testResult.Outcome, Is.EqualTo(TestOutcome.Passed));
|
||||
Assert.That(testResult.ErrorMessage, Is.EqualTo("It passed!"));
|
||||
CheckTestCase(testCase);
|
||||
|
||||
Assert.That(testResult.Outcome, Is.EqualTo(TestOutcome.Passed));
|
||||
Assert.That(testResult.ErrorMessage, Is.EqualTo("It passed!"));
|
||||
Assert.That(testResult.Duration, Is.EqualTo(TimeSpan.FromSeconds(1.234)));
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,10 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
{
|
||||
Assert.That(testCase.FullyQualifiedName, Is.EqualTo("NUnit.VisualStudio.TestAdapter.Tests.TestConverterTests.FakeTestCase"));
|
||||
Assert.That(testCase.DisplayName, Is.EqualTo("FakeTestCase"));
|
||||
Assert.That(testCase.Source, Is.SamePath(THIS_ASSEMBLY_PATH));
|
||||
|
||||
Assert.That(testCase.CodeFilePath, Is.SamePath(THIS_CODE_FILE));
|
||||
Assert.That(testCase.LineNumber, Is.EqualTo(FAKE_LINE_NUMBER));
|
||||
Assert.That(testCase.Source, Is.SamePath(THIS_ASSEMBLY_PATH));
|
||||
|
||||
Assert.That(testCase.CodeFilePath, Is.SamePath(THIS_CODE_FILE));
|
||||
Assert.That(testCase.LineNumber, Is.EqualTo(FAKE_LINE_NUMBER));
|
||||
|
||||
// Check traits using reflection, since the feature was added
|
||||
// in an update to VisualStudio and may not be present.
|
||||
|
|
|
@ -15,14 +15,14 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
[Category("TestConverter")]
|
||||
public class TestConverterTests_StaticHelpers
|
||||
{
|
||||
[TestCase(ResultState.Cancelled, Result = TestOutcome.None)]
|
||||
[TestCase(ResultState.Error, Result = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Failure, Result = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Ignored, Result = TestOutcome.Skipped)]
|
||||
[TestCase(ResultState.Inconclusive, Result = TestOutcome.None)]
|
||||
[TestCase(ResultState.NotRunnable, Result = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Skipped, Result = TestOutcome.Skipped)]
|
||||
[TestCase(ResultState.Success, Result = TestOutcome.Passed)]
|
||||
[TestCase(ResultState.Cancelled, ExpectedResult = TestOutcome.None)]
|
||||
[TestCase(ResultState.Error, ExpectedResult = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Failure, ExpectedResult = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Ignored, ExpectedResult = TestOutcome.Skipped)]
|
||||
[TestCase(ResultState.Inconclusive, ExpectedResult = TestOutcome.None)]
|
||||
[TestCase(ResultState.NotRunnable, ExpectedResult = TestOutcome.Failed)]
|
||||
[TestCase(ResultState.Skipped, ExpectedResult = TestOutcome.Skipped)]
|
||||
[TestCase(ResultState.Success, ExpectedResult = TestOutcome.Passed)]
|
||||
public TestOutcome ResultStateToTestOutcome(NUnit.Core.ResultState resultState)
|
||||
{
|
||||
return TestConverter.ResultStateToTestOutcome(resultState);
|
||||
|
|
|
@ -18,7 +18,9 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
|
||||
static readonly List<TestCase> testCases = new List<TestCase>();
|
||||
|
||||
[TestFixtureSetUp]
|
||||
private static ITestDiscoverer nunittestDiscoverer;
|
||||
|
||||
[SetUp]
|
||||
public void LoadMockassembly()
|
||||
{
|
||||
// Sanity check to be sure we have the correct version of mock-assembly.dll
|
||||
|
@ -27,7 +29,8 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
|
||||
// Load the NUnit mock-assembly.dll once for this test, saving
|
||||
// the list of test cases sent to the discovery sink
|
||||
((ITestDiscoverer)new NUnitTestDiscoverer()).DiscoverTests(new[] { mockAssemblyPath }, null, this, this);
|
||||
nunittestDiscoverer = ((ITestDiscoverer)new NUnitTestDiscoverer());
|
||||
nunittestDiscoverer.DiscoverTests(new[] { mockAssemblyPath }, null, this, this);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -13,9 +13,9 @@ using NUnit.Tests.Assemblies;
|
|||
using NUnit.VisualStudio.TestAdapter.Tests.Fakes;
|
||||
|
||||
namespace NUnit.VisualStudio.TestAdapter.Tests
|
||||
{
|
||||
using System.Diagnostics;
|
||||
|
||||
{
|
||||
using System.Diagnostics;
|
||||
|
||||
[Category("TestExecution")]
|
||||
public class TestExecutionTests
|
||||
{
|
||||
|
@ -26,6 +26,8 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
private List<TestResult> testResults;
|
||||
private ResultSummary summary;
|
||||
private FakeFrameworkHandle testLog;
|
||||
private static ITestExecutor executor;
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void LoadMockassembly()
|
||||
|
@ -39,11 +41,8 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
|
||||
// Load the NUnit mock-assembly.dll once for this test, saving
|
||||
// the list of test cases sent to the discovery sink
|
||||
((ITestExecutor)new NUnitTestExecutor()).RunTests(
|
||||
new[] { mockAssemblyPath },
|
||||
context,
|
||||
testLog);
|
||||
|
||||
executor = ((ITestExecutor) new NUnitTestExecutor());
|
||||
executor.RunTests(new[] { mockAssemblyPath }, context, testLog);
|
||||
this.summary = new ResultSummary(testResults);
|
||||
}
|
||||
|
||||
|
@ -66,8 +65,8 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void CorrectNumberOfResultsWereReceived()
|
||||
{
|
||||
public void CorrectNumberOfResultsWereReceived()
|
||||
{
|
||||
var eventType = FakeFrameworkHandle.EventType.RecordResult;
|
||||
Assert.That(
|
||||
testLog.Events.FindAll(e => e.EventType == eventType).Count,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.3.13283" newVersion="2.6.3.13283" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче