Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NUnit TheoryAttribute #2435

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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