[TestClass] and [TestMethod]

noun

say it: “TEST klas and TEST METH-ud” /tɛst klæs ænd tɛst ˈmɛθəd/

The two MSTest attributes that mark a class as holding tests and each method in it as one test.

What do [TestClass] and [TestMethod] mark in MSTest?

[TestClass] and [TestMethod] — The two MSTest attributes every test needs. [TestClass] marks a public class that holds tests, and [TestMethod] marks each method in it to run as one test. A method without it is never run.

[TestClass]
public class ScoreboardTests
{
    [TestMethod]
    public void HomeScores_AddsPoints() { /* ... */ }
}

In a sentence

  • “I forgot TestMethod on the new test, so the test runner never ran it.”

Level: Apprentice · More Unit Testing terms at this level

Updated