forked from OpenCover/opencover
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OpenCover#744 from sawilde/issue_742_nested_tests
OpenCover#742 support nested test classes and methods
- Loading branch information
Showing
7 changed files
with
184 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
main/OpenCover.Extensions/Strategy/TrackXUnitTestMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OpenCover.Extensions.Strategy | ||
{ | ||
/// <summary> | ||
/// Track xUnit test methods | ||
/// </summary> | ||
public class TrackXUnitTestMethods : TrackedMethodStrategyBase | ||
namespace OpenCover.Extensions.Strategy | ||
{ | ||
/// <summary> | ||
/// Track xUnit test methods | ||
/// </summary> | ||
public class TrackXUnitTestMethods : TrackedMethodStrategyBase | ||
{ | ||
private const string xUnitStrategyName = "xUnitTest"; | ||
private const string XUnitStrategyName = "xUnitTest"; | ||
|
||
private static readonly IList<string> TrackedAttributeTypeNames = new List<string> | ||
{ | ||
"Xunit.FactAttribute", | ||
"Xunit.TheoryAttribute", | ||
private static readonly IList<string> TrackedAttributeTypeNames = new List<string> | ||
{ | ||
"Xunit.FactAttribute", | ||
"Xunit.TheoryAttribute", | ||
}; | ||
|
||
public TrackXUnitTestMethods() : base(xUnitStrategyName, TrackedAttributeTypeNames) | ||
{ | ||
} | ||
} | ||
public TrackXUnitTestMethods() : base(XUnitStrategyName, TrackedAttributeTypeNames) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 81 additions & 69 deletions
150
main/OpenCover.Test/Extensions/Strategy/TrackNUnitTestMethodsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,93 @@ | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using OpenCover.Extensions.Strategy; | ||
|
||
namespace OpenCover.Test.Extensions.Strategy | ||
{ | ||
[TestFixture] | ||
public class TrackNUnitTestMethodsTests | ||
{ | ||
private TrackNUnitTestMethods strategy; | ||
private Mono.Cecil.AssemblyDefinition assemblyDefinition; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
strategy = new TrackNUnitTestMethods(); | ||
assemblyDefinition = Mono.Cecil.AssemblyDefinition.ReadAssembly(typeof(TrackNUnitTestMethodsTests).Assembly.Location); | ||
} | ||
|
||
[Test] | ||
public void Can_Identify_Methods() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = strategy.GetTrackedMethods(assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::ASingleTest()"))); | ||
} | ||
|
||
[Test] | ||
public void TestAttribute_Is_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = strategy.GetTrackedMethods(assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::ASingleTestCase()"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void TheoryAttribute_Is_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = strategy.GetTrackedMethods(assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::TheoryTest(System.Double)"))); | ||
} | ||
|
||
using System.Linq; | ||
using NUnit.Framework; | ||
using OpenCover.Extensions.Strategy; | ||
|
||
namespace OpenCover.Test.Extensions.Strategy | ||
{ | ||
[TestFixture] | ||
public class TrackNUnitTestMethodsTests | ||
{ | ||
private TrackNUnitTestMethods _strategy; | ||
private Mono.Cecil.AssemblyDefinition _assemblyDefinition; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_strategy = new TrackNUnitTestMethods(); | ||
_assemblyDefinition = Mono.Cecil.AssemblyDefinition.ReadAssembly(typeof(TrackNUnitTestMethodsTests).Assembly.Location); | ||
} | ||
|
||
[Test] | ||
public void Can_Identify_Methods() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::ASingleTest()"))); | ||
} | ||
|
||
[Test] | ||
public void TestAttribute_Is_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::ASingleTestCase()"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void TheoryAttribute_Is_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::TheoryTest(System.Double)"))); | ||
} | ||
|
||
[Test] | ||
public void TestCaseSourceAttribute_Is_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = strategy.GetTrackedMethods(assemblyDefinition.MainModule.Types); | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::DivideTest(System.Int32,System.Int32,System.Int32)"))); | ||
} | ||
|
||
[Test] | ||
public void Repeat_Is_Not_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = strategy.GetTrackedMethods(assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.False(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::RepeatWithoutTest()"))); | ||
} | ||
} | ||
[Test] | ||
public void Repeat_Is_Not_Recognized() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.False(methods.Any(x => x.FullName.EndsWith("SimpleNUnit::RepeatWithoutTest()"))); | ||
} | ||
|
||
[Test] | ||
public void Can_Identify_Methods_InNestedClasses() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var methods = _strategy.GetTrackedMethods(_assemblyDefinition.MainModule.Types); | ||
|
||
// assert | ||
Assert.True(methods.Any(x => x.FullName.EndsWith(".Samples.ComplexNUnit/InnerTests::InnerExecuteMethod()"))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using NUnit.Framework; | ||
|
||
namespace OpenCover.Test.Samples | ||
{ | ||
[TestFixture] | ||
public class ComplexNUnit | ||
{ | ||
[TestFixture] | ||
public class InnerTests | ||
{ | ||
[Test] | ||
public void InnerExecuteMethod() | ||
{ | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.