user746461
user746461

Reputation:

Can I use static test methods?

I'm trying MS Test. Visual Studio doesn't find any tests from the following code unless I remove the static keyword.

[TestClass]
public static class TestMain2
{

    [TestMethod]
    public static void TestMergeWildcard()
    {
         ....
    }
}

I guess MS Test doesn't support static test methods.

Is there a documentation stating this limitation or did I only miss some attribute or need to turn on an option?

I used "MS Test static test methods" in Google search, but all results are about testing static methods..

Upvotes: 0

Views: 221

Answers (1)

Sebastian Kilb
Sebastian Kilb

Reputation: 286

Why do you want to make both the class and method static?
Normally you mark them as [TestClass] and [TestMethod] and run the tests.

Maybe this helps.
https://learn.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing

Upvotes: 0

Related Questions