2013-05-30 48 views
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()); 
    } 
} 

回答

1

使用PowerMockIgnore推迟两次冲突类的加载。您提到的dll swt-win32-3650.dll可能已经被加载。所以检查可以做到这一点的类,并将它们放入PowerMockIgnore争论中。

相关问题