when use junit4 + powermock to execute all test suites , I got an error : swt-win32-3650.dll already loaded in another classloader 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() );
}
}
Use PowerMockIgnore to defer loading of conflicting classes twice. The dll swt-win32-3650.dll that you have mentioned would have been probably already loaded. So check for classes which can do this and put them in PowerMockIgnore arguements'.