Skip to content

Commit

Permalink
Merge pull request #2435 from 333fred/nunit-theory
Browse files Browse the repository at this point in the history
Support NUnit TheoryAttribute
  • Loading branch information
filipw authored Aug 15, 2022
2 parents e06a8bf + ec96884 commit 9b021d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ protected override bool IsTestAttributeName(string typeName)
{
return typeName == "NUnit.Framework.TestAttribute"
|| typeName == "NUnit.Framework.TestCaseAttribute"
|| typeName == "NUnit.Framework.TestCaseSourceAttribute";
|| typeName == "NUnit.Framework.TestCaseSourceAttribute"
|| typeName == "NUnit.Framework.Theory";
}
}
}
13 changes: 13 additions & 0 deletions test-assets/test-projects/NUnitTestProject/TestProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,17 @@ public void M()

}
}

[TestFixture(typeof(int))]
public class TheorySampleTestsGeneric<T>
{
[Datapoint]
public int[] ArrayInt = { 0, 1, 2, 3 };

[Theory]
public void TestGenericForArbitraryArray(T[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}
}
}
12 changes: 12 additions & 0 deletions tests/OmniSharp.DotNetTest.Tests/RunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ public async Task RunNunitTypedTestRunsTwice()
Assert.Equal(2, response.Results.Length);
}

[Fact]
public async Task RunNunitTheoryTest()
{
var response = await RunDotNetTestAsync(
NUnitTestProject,
methodName: "Main.Test.TheorySampleTestsGeneric`1.TestGenericForArbitraryArray",
testFramework: "nunit",
shouldPass: true);

Assert.Single(response.Results);
}

[Fact]
public async Task RunMSTestTest()
{
Expand Down

0 comments on commit 9b021d7

Please sign in to comment.