I have 2-3 inner classes which have some test cases and those are running well(being tested). I also have some test cases in outer class but these test cases are not running. I have the following structure:
@org.junit.runner.RunWith(Enclosed.class)
public class Outer {
@Test
public void test1() {
assert("Outer" != null);
}
public static class Inner1 {
@Test
public void test2() {
assert("Inner1" != null);
}
}
public static class Inner2 {
@Test
public void test3() {
assert("Inner2" != null);
}
}
}
When I run this code, only test2 and test3 are being tested. test1 is not running. I want to run all test cases. So is this possible with Junit4 or is there any other way to achieve this?
Thanks in advance.
A work-around would be to put all tests from Outer into a new inner class:
@org.junit.runner.RunWith(Enclosed.class)
public class Outer {
public static class Inner {
@Test
public void test1() {
assert ("Outer" != null);
}
}
public static class Inner1 {
@Test
public void test2() {
assert ("Inner1" != null);
}
}
public static class Inner2 {
@Test
public void test3() {
assert ("Inner2" != null);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.