Test cases in inner classes with JUnit

You should annontate your class with @RunWith(Enclosed.class), and like others said, declare the inner classes as static: @RunWith(Enclosed.class) public class DogTests { public static class BarkTests { @Test public void quietBark_IsAtLeastAudible() { } @Test public void loudBark_ScaresAveragePerson() { } } public static class EatTests { @Test public void normalFood_IsEaten() { } @Test public void badFood_ThrowsFit() … Read more

Eclipse Java IDE JUnit5: junit.jupiter.api.Assertions is not accessible

You use the Java Platform Module System (JPMS) by having a module-info.java file in the default package probably without the required requires <module>; statement. JPMS was introduced in Java 9. Do one of the following: Delete the module-info.java file (if needed, you can recreate it via right-clicking the project folder and choosing Configure > Create … Read more

Does MSTest have an equivalent to NUnit’s TestCase?

Microsoft recently announced “MSTest V2” (see blog-article). This allows you to consistently (desktop, UWP, …) use the DataRow-attribute! [TestClass] public class StringFormatUtilsTest { [DataTestMethod] [DataRow(“tttt”, “”)] [DataRow(“”, “”)] [DataRow(“t3a4b5”, “345”)] [DataRow(“3&amp;amp;5*”, “35”)] [DataRow(“123”, “123”)] public void StripNonNumeric(string before, string expected) { string actual = FormatUtils.StripNonNumeric(before); Assert.AreEqual(expected, actual); } } Again, Visual Studio Express’ Test Explorer … Read more