使用 junit4 + powermock 执行所有测试套件时,出现错误:swt-win32-3650.dll 已加载到另一个类加载器 alltest.java 中:
@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() );
}
}