4
當使用junit4 + powermock來執行所有測試套件時,我得到一個錯誤:swt-win32 -3650.dll已裝入另一個類加載器 alltest.java:當使用junit4 + powermock來執行所有測試套件時,我得到一個錯誤:swt-win32-3650.dll已經在另一個類加載器中加載
@RunWith(Suite.class)
@SuiteClasses({test1.class, test2.class})
public class AllTests
{
}
test1.java
@RunWith(PowerMockRunner.class)
@PrepareOnlyThisForTest({Object.class})
public class test1 extends TestCase
{
@Test
public void testcase()
{
Shell sh = Mockito.mock(Shell.class);
PowerMockito.when(sh.getText())
.thenReturn(this.getClass().getName());
PowerMockito.when(sh.getText())
.thenReturn(this.getClass().getName());
assertTrue(sh.getText() == this.getClass().getName());
}
}
test2.java
@RunWith(PowerMockRunner.class)
@PrepareOnlyThisForTest({Object.class})
public class test2 extends TestCase
{
@Test
public void testcase()
{
Shell sh = Mockito.mock(Shell.class);
PowerMockito.when(sh.getText())
.thenReturn(this.getClass().getName());
assertTrue(sh.getText() == this.getClass().getName());
}
}