7
我正在試驗JUnit Enclosed
轉輪以試圖改進我的一些測試的組織。目前我正在努力研究如何在內部類之間共享一些設置。JUnit封閉的轉輪和共享設置
嘗試第一:
@RunWith(Enclosed.class)
public class EnclosedTest {
@Before
public void printSomething() {
System.out.println("Helllooo Meggan");
}
public static class FirstTest {
@Test
public void assertThatSomethingIsTrue() {
assertThat(true, is(true));
}
}
public static class SecondTest {
@Test
public void assertThatSomethingIsFalse() {
assertThat(false, is(false));
}
}
}
不幸的是,沒有人說打招呼Meggan。如果我更新的內部類擴展外一個,然後我得到如下:
java.lang.Exception: class 'org.scratch.EnclosedTest$FirstTest' (possibly indirectly) contains itself as a SuiteClass
at org.junit.runners.model.InitializationError.<init>(InitializationError.java:32)
是否有特定Enclosed
成語試圖分享內部測試類之間建立何時使用?我希望它會像C# example I found一樣簡單。