Updated code. Set version to 0.9.0.
This commit is contained in:
Родитель
f8f5ba8c60
Коммит
d5cbf26cce
|
@ -23,7 +23,7 @@ namespace TestGeneration.Extensions.NUnit
|
|||
public class NUnitFrameworkProvider : FrameworkProviderBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NUnit2FrameworkProvider"/> class.
|
||||
/// Initializes a new instance of the <see cref="NUnitFrameworkProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider">The service provider to use to get the interfaces required.</param>
|
||||
/// <param name="configurationSettings">The configuration settings object to be used to determine how the test method is generated.</param>
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace TestGeneration.Extensions.NUnit
|
|||
TraceLogger.LogInfo("NUnitSolutionManager.OnUnitTestProjectCreated: Adding reference to NUnit assemblies through nuget.");
|
||||
|
||||
base.OnUnitTestProjectCreated(unitTestProject, sourceMethod);
|
||||
this.EnsureNuGetReference(unitTestProject, "NUnit", "3.0.0-beta-2");
|
||||
this.EnsureNuGetReference(unitTestProject, "NUnit", "3.0.0-beta-3");
|
||||
|
||||
var vsp = unitTestProject.Object as VSProject2;
|
||||
var reference = vsp?.References.Find(GlobalConstants.MSTestAssemblyName);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\Osiris.Extended.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.ExtendedReflection">
|
||||
|
@ -53,6 +54,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NUnit2TestFramework.cs" />
|
||||
<Compile Include="NUnitAssertMethodFilter.cs" />
|
||||
<Compile Include="NUnitTestFramework.cs" />
|
||||
<Compile Include="NUnitTestFrameworkMetadata.cs" />
|
||||
|
|
|
@ -0,0 +1,379 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.ExtendedReflection.Asserts;
|
||||
using Microsoft.ExtendedReflection.Collections;
|
||||
using Microsoft.ExtendedReflection.Metadata;
|
||||
using Microsoft.ExtendedReflection.Metadata.Names;
|
||||
using Microsoft.ExtendedReflection.Monitoring;
|
||||
using Microsoft.ExtendedReflection.Utilities;
|
||||
using Microsoft.ExtendedReflection.Utilities.Safe;
|
||||
using Microsoft.ExtendedReflection.Utilities.Safe.Diagnostics;
|
||||
using Microsoft.Pex.Engine.ComponentModel;
|
||||
using Microsoft.Pex.Engine.TestFrameworks;
|
||||
|
||||
namespace TestGeneration.Extensions.IntelliTest.NUnit
|
||||
{
|
||||
/// <summary>
|
||||
/// NUnit 2 test framework
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
sealed class NUnit2TestFramework : AttributeBasedTestFrameworkBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NUnit2TestFramework"/> class.
|
||||
/// </summary>
|
||||
/// <param name="host">
|
||||
/// </param>
|
||||
public NUnit2TestFramework(IPexComponent host)
|
||||
: base(host)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// identify of the test framework
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override string Name => "NUnit2";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assembly name of the framework main's assembly. This name is used
|
||||
/// to automatically discover test frameworks, based the assembly references
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override ShortAssemblyName AssemblyName => NUnitTestFrameworkMetadata.AssemblyName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root namespace.
|
||||
/// </summary>
|
||||
/// <value>The root namespace.</value>
|
||||
public override string RootNamespace => NUnitTestFrameworkMetadata.RootNamespace;
|
||||
|
||||
/// <summary>
|
||||
/// The test framework references.
|
||||
/// </summary>
|
||||
public override ICountable<ShortReferenceAssemblyName> References => Indexable.One(new ShortReferenceAssemblyName(ShortAssemblyName.FromName("NUnit"), "2.6.4", AssemblyReferenceType.NugetReference));
|
||||
|
||||
/// <summary>
|
||||
/// The _directory.
|
||||
/// </summary>
|
||||
private string directory = null;
|
||||
|
||||
/// <summary>
|
||||
/// Hint on the location of the test framework assembly
|
||||
/// </summary>
|
||||
/// <param name="pdirectory">
|
||||
/// The directory.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryGetDirectory(out string pdirectory)
|
||||
{
|
||||
if (directory == null)
|
||||
{
|
||||
var programFiles = new DirectoryInfo(Environment.ExpandEnvironmentVariables("%ProgramFiles%"));
|
||||
var info = programFiles.GetDirectories("NUnit-Net-*", SearchOption.TopDirectoryOnly);
|
||||
directory = info.Length == 0 ? string.Empty : Path.Combine(info[0].FullName, "bin");
|
||||
}
|
||||
|
||||
pdirectory = directory;
|
||||
return !SafeString.IsNullOrEmpty(directory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether
|
||||
/// partial test classes
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override bool SupportsPartialClasses => true;
|
||||
|
||||
/// <summary>
|
||||
/// The supports project bitness.
|
||||
/// </summary>
|
||||
/// <param name="bitness">
|
||||
/// The bitness.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool SupportsProjectBitness(Bitness bitness)
|
||||
{
|
||||
SafeDebug.Assume(bitness != Bitness.Unsupported, "bitness != Bitness.Unsupported");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _expected exception attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName expectedExceptionAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ExpectedException attribute.
|
||||
/// </summary>
|
||||
/// <value>The expected exception attribute.</value>
|
||||
public override TypeName ExpectedExceptionAttribute => expectedExceptionAttribute ??
|
||||
(expectedExceptionAttribute = NUnitTestFrameworkMetadata.AttributeName("ExpectedException"));
|
||||
|
||||
/// <summary>
|
||||
/// Tries the read expected exception.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// The method.
|
||||
/// </param>
|
||||
/// <param name="exceptionType">
|
||||
/// Type of the exception.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
|
||||
{
|
||||
var attribute = AttributeHelper.GetAttribute(target, ExpectedExceptionAttribute);
|
||||
if (attribute != null)
|
||||
{
|
||||
var attributeType = attribute.GetType();
|
||||
|
||||
// read exception type using reflection.
|
||||
var field = attributeType.GetField("expectedException", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (field != null)
|
||||
{
|
||||
var t = field.GetValue(attribute) as Type;
|
||||
bool isClass;
|
||||
if (t != null && ReflectionHelper.TryGetIsClass(t, out isClass) && isClass
|
||||
&& !ReflectionHelper.ContainsGenericParameters(t))
|
||||
{
|
||||
exceptionType = MetadataFromReflection.GetType(t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exceptionType = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the assembly set up tear down attribute.
|
||||
/// </summary>
|
||||
/// <param name="assembly">
|
||||
/// The assembly.
|
||||
/// </param>
|
||||
/// <param name="setUp">
|
||||
/// The set up.
|
||||
/// </param>
|
||||
/// <param name="tearDown">
|
||||
/// The tear down.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryGetAssemblySetupTeardownMethods(AssemblyEx assembly, out Method setUp, out Method tearDown)
|
||||
{
|
||||
setUp = null;
|
||||
tearDown = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether[fixture set up tear down are instance methods.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [fixture set up tear down instance]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public override bool FixtureSetupTeardownInstance => true;
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture attribute.</value>
|
||||
public override TypeName FixtureAttribute => fixtureAttribute ??
|
||||
(fixtureAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixture"));
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture set up attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureSetUpAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture setup attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture set up attribute.</value>
|
||||
public override TypeName FixtureSetupAttribute => fixtureSetUpAttribute ??
|
||||
(fixtureSetUpAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixtureSetUp"));
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture tear down attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureTearDownAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture teardown attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture tear down attribute.</value>
|
||||
public override TypeName FixtureTeardownAttribute => fixtureTearDownAttribute ??
|
||||
(fixtureTearDownAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixtureTearDown"));
|
||||
|
||||
/// <summary>
|
||||
/// The _set up attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName setUpAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test setup attribute.
|
||||
/// </summary>
|
||||
/// <value>The set up attribute.</value>
|
||||
public override TypeName SetupAttribute => setUpAttribute ??
|
||||
(setUpAttribute = NUnitTestFrameworkMetadata.AttributeName("SetUp"));
|
||||
|
||||
/// <summary>
|
||||
/// The _test attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName testAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test attribute.
|
||||
/// </summary>
|
||||
/// <value>The set up attribute.</value>
|
||||
public override TypeName TestAttribute => testAttribute ?? (testAttribute = NUnitTestFrameworkMetadata.AttributeName("Test"));
|
||||
|
||||
/// <summary>
|
||||
/// The _tear down attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName tearDownAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test teardown attribute.
|
||||
/// </summary>
|
||||
/// <value>The tear down attribute.</value>
|
||||
public override TypeName TeardownAttribute => tearDownAttribute ??
|
||||
(tearDownAttribute = NUnitTestFrameworkMetadata.AttributeName("TearDown"));
|
||||
|
||||
/// <summary>
|
||||
/// The _ignore attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName ignoreAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ignore attribute.
|
||||
/// </summary>
|
||||
/// <value>The ignore attribute.</value>
|
||||
public override TypeName IgnoreAttribute => ignoreAttribute ??
|
||||
(ignoreAttribute = NUnitTestFrameworkMetadata.AttributeName("Ignore"));
|
||||
|
||||
/// <summary>
|
||||
/// Whether the ignore attribute constructor takes a message as its first argument.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
protected override bool HasIgnoreAttributeMessage => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ignore message property.
|
||||
/// </summary>
|
||||
/// <value>The ignore message property.</value>
|
||||
protected override string IgnoreMessageProperty => "Reason";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the expected exception property name.
|
||||
/// </summary>
|
||||
/// <value>The expected exception property.</value>
|
||||
protected override string ExpectedExceptionProperty => "ExceptionType";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of attribute that should be duplicated from the
|
||||
/// pex test to the parameterized test
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The <see cref="IEnumerable"/>.
|
||||
/// </returns>
|
||||
protected override IEnumerable<TypeName> GetSatelliteAttributeTypes()
|
||||
{
|
||||
return Indexable.Array(CategoryAttribute,
|
||||
NUnitTestFrameworkMetadata.AttributeName("Description"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Explicit"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Platform"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Property")
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _category attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName categoryAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category attribute.
|
||||
/// </summary>
|
||||
private TypeName CategoryAttribute => categoryAttribute ??
|
||||
(categoryAttribute = NUnitTestFrameworkMetadata.AttributeName("Category"));
|
||||
|
||||
/// <summary>
|
||||
/// Tries the get categories.
|
||||
/// </summary>
|
||||
/// <param name="element">
|
||||
/// The element.
|
||||
/// </param>
|
||||
/// <param name="names">
|
||||
/// The names.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
protected override bool TryGetCategories( ICustomAttributeProviderEx element, out IEnumerable<string> names)
|
||||
{
|
||||
SafeDebug.AssumeNotNull(element, "element");
|
||||
|
||||
// TODO
|
||||
names = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _assertion exception type.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName assertionExceptionType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the assertion exception.
|
||||
/// </summary>
|
||||
/// <value>The type of the assertion exception.</value>
|
||||
public override TypeName AssertionExceptionType
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Diagnostics.Debugger.Launch();
|
||||
return assertionExceptionType ?? (assertionExceptionType = TypeDefinitionName.FromName(
|
||||
NUnitTestFrameworkMetadata.AssemblyName,
|
||||
-1,
|
||||
false,
|
||||
NUnitTestFrameworkMetadata.RootNamespace,
|
||||
"AssertionException").SelfInstantiation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether supports static test methods.
|
||||
/// </summary>
|
||||
public override bool SupportsStaticTestMethods => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assert method filters.
|
||||
/// </summary>
|
||||
public override IIndexable<IAssertMethodFilter> AssertMethodFilters => Indexable.One<IAssertMethodFilter>(NUnitAssertMethodFilter.Instance);
|
||||
}
|
||||
}
|
|
@ -25,369 +25,6 @@ namespace TestGeneration.Extensions.IntelliTest.NUnit
|
|||
using Microsoft.Pex.Engine.ComponentModel;
|
||||
using Microsoft.Pex.Engine.TestFrameworks;
|
||||
|
||||
/// <summary>
|
||||
/// NUnit 2 test framework
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
sealed class NUnit2TestFramework : AttributeBasedTestFrameworkBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NUnit2TestFramework"/> class.
|
||||
/// </summary>
|
||||
/// <param name="host">
|
||||
/// </param>
|
||||
public NUnit2TestFramework(IPexComponent host)
|
||||
: base(host)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// identify of the test framework
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override string Name => "NUnit2";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assembly name of the framework main's assembly. This name is used
|
||||
/// to automatically discover test frameworks, based the assembly references
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override ShortAssemblyName AssemblyName => NUnitTestFrameworkMetadata.AssemblyName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root namespace.
|
||||
/// </summary>
|
||||
/// <value>The root namespace.</value>
|
||||
public override string RootNamespace => NUnitTestFrameworkMetadata.RootNamespace;
|
||||
|
||||
/// <summary>
|
||||
/// The test framework references.
|
||||
/// </summary>
|
||||
public override ICountable<ShortReferenceAssemblyName> References => Indexable.One(new ShortReferenceAssemblyName(ShortAssemblyName.FromName("NUnit"), "2.6.4", AssemblyReferenceType.NugetReference));
|
||||
|
||||
/// <summary>
|
||||
/// The _directory.
|
||||
/// </summary>
|
||||
private string directory = null;
|
||||
|
||||
/// <summary>
|
||||
/// Hint on the location of the test framework assembly
|
||||
/// </summary>
|
||||
/// <param name="pdirectory">
|
||||
/// The directory.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryGetDirectory(out string pdirectory)
|
||||
{
|
||||
if (directory == null)
|
||||
{
|
||||
var programFiles = new DirectoryInfo(Environment.ExpandEnvironmentVariables("%ProgramFiles%"));
|
||||
var info = programFiles.GetDirectories("NUnit-Net-*", SearchOption.TopDirectoryOnly);
|
||||
directory = info.Length == 0 ? string.Empty : Path.Combine(info[0].FullName, "bin");
|
||||
}
|
||||
|
||||
pdirectory = directory;
|
||||
return !SafeString.IsNullOrEmpty(directory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether
|
||||
/// partial test classes
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public override bool SupportsPartialClasses => true;
|
||||
|
||||
/// <summary>
|
||||
/// The supports project bitness.
|
||||
/// </summary>
|
||||
/// <param name="bitness">
|
||||
/// The bitness.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool SupportsProjectBitness(Bitness bitness)
|
||||
{
|
||||
SafeDebug.Assume(bitness != Bitness.Unsupported, "bitness != Bitness.Unsupported");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _expected exception attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName expectedExceptionAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ExpectedException attribute.
|
||||
/// </summary>
|
||||
/// <value>The expected exception attribute.</value>
|
||||
public override TypeName ExpectedExceptionAttribute => expectedExceptionAttribute ??
|
||||
(expectedExceptionAttribute = NUnitTestFrameworkMetadata.AttributeName("ExpectedException"));
|
||||
|
||||
/// <summary>
|
||||
/// Tries the read expected exception.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// The method.
|
||||
/// </param>
|
||||
/// <param name="exceptionType">
|
||||
/// Type of the exception.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
|
||||
{
|
||||
var attribute = AttributeHelper.GetAttribute(target, ExpectedExceptionAttribute);
|
||||
if (attribute != null)
|
||||
{
|
||||
var attributeType = attribute.GetType();
|
||||
|
||||
// read exception type using reflection.
|
||||
var field = attributeType.GetField("expectedException", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (field != null)
|
||||
{
|
||||
var t = field.GetValue(attribute) as Type;
|
||||
bool isClass;
|
||||
if (t != null && ReflectionHelper.TryGetIsClass(t, out isClass) && isClass
|
||||
&& !ReflectionHelper.ContainsGenericParameters(t))
|
||||
{
|
||||
exceptionType = MetadataFromReflection.GetType(t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exceptionType = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the assembly set up tear down attribute.
|
||||
/// </summary>
|
||||
/// <param name="assembly">
|
||||
/// The assembly.
|
||||
/// </param>
|
||||
/// <param name="setUp">
|
||||
/// The set up.
|
||||
/// </param>
|
||||
/// <param name="tearDown">
|
||||
/// The tear down.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
public override bool TryGetAssemblySetupTeardownMethods(AssemblyEx assembly, out Method setUp, out Method tearDown)
|
||||
{
|
||||
setUp = null;
|
||||
tearDown = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether[fixture set up tear down are instance methods.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [fixture set up tear down instance]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public override bool FixtureSetupTeardownInstance => true;
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture attribute.</value>
|
||||
public override TypeName FixtureAttribute => fixtureAttribute ??
|
||||
(fixtureAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixture"));
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture set up attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureSetUpAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture setup attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture set up attribute.</value>
|
||||
public override TypeName FixtureSetupAttribute => fixtureSetUpAttribute ??
|
||||
(fixtureSetUpAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixtureSetUp"));
|
||||
|
||||
/// <summary>
|
||||
/// The _fixture tear down attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName fixtureTearDownAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the fixture teardown attribute
|
||||
/// </summary>
|
||||
/// <value>The fixture tear down attribute.</value>
|
||||
public override TypeName FixtureTeardownAttribute => fixtureTearDownAttribute ??
|
||||
(fixtureTearDownAttribute = NUnitTestFrameworkMetadata.AttributeName("TestFixtureTearDown"));
|
||||
|
||||
/// <summary>
|
||||
/// The _set up attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName setUpAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test setup attribute.
|
||||
/// </summary>
|
||||
/// <value>The set up attribute.</value>
|
||||
public override TypeName SetupAttribute => setUpAttribute ??
|
||||
(setUpAttribute = NUnitTestFrameworkMetadata.AttributeName("SetUp"));
|
||||
|
||||
/// <summary>
|
||||
/// The _test attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName testAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test attribute.
|
||||
/// </summary>
|
||||
/// <value>The set up attribute.</value>
|
||||
public override TypeName TestAttribute => testAttribute ?? (testAttribute = NUnitTestFrameworkMetadata.AttributeName("Test"));
|
||||
|
||||
/// <summary>
|
||||
/// The _tear down attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName tearDownAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the test teardown attribute.
|
||||
/// </summary>
|
||||
/// <value>The tear down attribute.</value>
|
||||
public override TypeName TeardownAttribute => tearDownAttribute ??
|
||||
(tearDownAttribute = NUnitTestFrameworkMetadata.AttributeName("TearDown"));
|
||||
|
||||
/// <summary>
|
||||
/// The _ignore attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName ignoreAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ignore attribute.
|
||||
/// </summary>
|
||||
/// <value>The ignore attribute.</value>
|
||||
public override TypeName IgnoreAttribute => ignoreAttribute ??
|
||||
(ignoreAttribute = NUnitTestFrameworkMetadata.AttributeName("Ignore"));
|
||||
|
||||
/// <summary>
|
||||
/// Whether the ignore attribute constructor takes a message as its first argument.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
protected override bool HasIgnoreAttributeMessage => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ignore message property.
|
||||
/// </summary>
|
||||
/// <value>The ignore message property.</value>
|
||||
protected override string IgnoreMessageProperty => "Reason";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the expected exception property name.
|
||||
/// </summary>
|
||||
/// <value>The expected exception property.</value>
|
||||
protected override string ExpectedExceptionProperty => "ExceptionType";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of attribute that should be duplicated from the
|
||||
/// pex test to the parameterized test
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The <see cref="IEnumerable"/>.
|
||||
/// </returns>
|
||||
protected override IEnumerable<TypeName> GetSatelliteAttributeTypes()
|
||||
{
|
||||
return Indexable.Array(CategoryAttribute,
|
||||
NUnitTestFrameworkMetadata.AttributeName("Description"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Explicit"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Platform"),
|
||||
NUnitTestFrameworkMetadata.AttributeName("Property")
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _category attribute.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName categoryAttribute;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category attribute.
|
||||
/// </summary>
|
||||
private TypeName CategoryAttribute => categoryAttribute ??
|
||||
(categoryAttribute = NUnitTestFrameworkMetadata.AttributeName("Category"));
|
||||
|
||||
/// <summary>
|
||||
/// Tries the get categories.
|
||||
/// </summary>
|
||||
/// <param name="element">
|
||||
/// The element.
|
||||
/// </param>
|
||||
/// <param name="names">
|
||||
/// The names.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="bool"/>.
|
||||
/// </returns>
|
||||
protected override bool TryGetCategories( ICustomAttributeProviderEx element, out IEnumerable<string> names)
|
||||
{
|
||||
SafeDebug.AssumeNotNull(element, "element");
|
||||
|
||||
// TODO
|
||||
names = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _assertion exception type.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
TypeName assertionExceptionType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the assertion exception.
|
||||
/// </summary>
|
||||
/// <value>The type of the assertion exception.</value>
|
||||
public override TypeName AssertionExceptionType
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Diagnostics.Debugger.Launch();
|
||||
return assertionExceptionType ?? (assertionExceptionType = TypeDefinitionName.FromName(
|
||||
NUnitTestFrameworkMetadata.AssemblyName,
|
||||
-1,
|
||||
false,
|
||||
NUnitTestFrameworkMetadata.RootNamespace,
|
||||
"AssertionException").SelfInstantiation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether supports static test methods.
|
||||
/// </summary>
|
||||
public override bool SupportsStaticTestMethods => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assert method filters.
|
||||
/// </summary>
|
||||
public override IIndexable<IAssertMethodFilter> AssertMethodFilters => Indexable.One<IAssertMethodFilter>(NUnitAssertMethodFilter.Instance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// NUnit 2 test framework
|
||||
|
@ -426,7 +63,7 @@ namespace TestGeneration.Extensions.IntelliTest.NUnit
|
|||
/// <summary>
|
||||
/// The test framework references.
|
||||
/// </summary>
|
||||
public override ICountable<ShortReferenceAssemblyName> References => Indexable.One(new ShortReferenceAssemblyName(ShortAssemblyName.FromName("NUnit"), "3.0.0-beta-2", AssemblyReferenceType.NugetReference));
|
||||
public override ICountable<ShortReferenceAssemblyName> References => Indexable.One(new ShortReferenceAssemblyName(ShortAssemblyName.FromName("NUnit"), "3.0.0-beta-3", AssemblyReferenceType.NugetReference));
|
||||
|
||||
/// <summary>
|
||||
/// The _directory.
|
||||
|
|
|
@ -11,7 +11,7 @@ using Microsoft.Pex.Framework.Packages;
|
|||
|
||||
using TestGeneration.Extensions.IntelliTest.NUnit;
|
||||
|
||||
[assembly: PexPackageType(typeof(NUnit2TestFrameworkPackage))]
|
||||
|
||||
[assembly: PexPackageType(typeof(NUnitTestFrameworkPackage))]
|
||||
|
||||
namespace TestGeneration.Extensions.IntelliTest.NUnit
|
||||
|
@ -22,28 +22,7 @@ namespace TestGeneration.Extensions.IntelliTest.NUnit
|
|||
|
||||
using Microsoft.Pex.Framework.Packages;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions package for NUnit.
|
||||
/// </summary>
|
||||
public class Nunit2TestFrameworkPackageAttribute : PexPackageAttributeBase
|
||||
{
|
||||
protected override void Initialize(IEngine engine)
|
||||
{
|
||||
base.Initialize(engine);
|
||||
|
||||
var testFrameworkService = engine.GetService<IPexTestFrameworkManager>();
|
||||
var host = testFrameworkService as IPexComponent;
|
||||
|
||||
testFrameworkService.AddTestFramework(new NUnit2TestFramework(host));
|
||||
}
|
||||
|
||||
public override string Name => nameof(NUnit2TestFrameworkPackage);
|
||||
}
|
||||
|
||||
[Nunit2TestFrameworkPackage]
|
||||
static class NUnit2TestFrameworkPackage
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class NunitTestFrameworkPackageAttribute : PexPackageAttributeBase
|
||||
|
@ -56,7 +35,9 @@ namespace TestGeneration.Extensions.IntelliTest.NUnit
|
|||
var host = testFrameworkService as IPexComponent;
|
||||
|
||||
testFrameworkService.AddTestFramework(new NUnitTestFramework(host));
|
||||
testFrameworkService.AddTestFramework(new NUnit2TestFramework(host));
|
||||
}
|
||||
|
||||
|
||||
public override string Name => nameof(NUnitTestFrameworkPackage);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<Include Path="globalizationrules.ruleset" Action="Default" />
|
||||
<Include Path="minimumrecommendedrules.ruleset" Action="Default" />
|
||||
<Rules AnalyzerId="CodeCracker.CSharp" RuleNamespace="CodeCracker.CSharp">
|
||||
<Rule Id="CC0001" Action="None" />
|
||||
<Rule Id="CC0065" Action="None" />
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
|
|
|
@ -54,6 +54,14 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="nunit3_32x32.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="preview.jpg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="stylesheet.css" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) <2015> <Microsoft Corporation>
|
||||
Copyright (c) <2015> <Terje Sandstrom>
|
||||
Copyright (c) <2015> <NUnit.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 1.5 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 6.9 KiB |
|
@ -1,11 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
|
||||
<Metadata>
|
||||
<Identity Id="TestGeneration.Extensions.NUnit.113f61ed-a246-4431-809d-bcd393642488" Version="1.0.0" Language="en-US" Publisher="Terje Sandstrom" />
|
||||
<DisplayName>Test Generation NUnit extensions</DisplayName>
|
||||
<Description xml:space="preserve">Test Generation NUnit extensions
|
||||
<Identity Id="TestGeneration.Extensions.NUnit.113f61ed-a246-4431-809d-bcd393642488" Version="0.9.0" Language="en-US" Publisher="Microsoft, NUnit.Org, Terje Sandstrom" />
|
||||
<DisplayName>Test Generator NUnit extension</DisplayName>
|
||||
<Description xml:space="preserve">Test Generator, NUnit extensions for Visual Studio 2015.
|
||||
Creates Unit tests and Initellitests with both NUnit 2.6.4 and NUnit 3 beta frameworks.
|
||||
</Description>
|
||||
<MoreInfo>https://github.com/nunit/nunit-vs-testgenerator/wiki</MoreInfo>
|
||||
<License>license.txt</License>
|
||||
<Icon>nunit3_32x32.png</Icon>
|
||||
<PreviewImage>preview.jpg</PreviewImage>
|
||||
<Tags>unit testing, NUnit</Tags>
|
||||
</Metadata>
|
||||
<Installation>
|
||||
|
|
Загрузка…
Ссылка в новой задаче