当使用junit4 + powermock执行所有测试套件时,我收到一个错误:swt-win32-3650.dll已经加载到另一个类加载器 [英] when use junit4 + powermock to execute all test suites , I got an error : swt-win32-3650.dll already loaded in another classloader

查看:164
本文介绍了当使用junit4 + powermock执行所有测试套件时,我收到一个错误:swt-win32-3650.dll已经加载到另一个类加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用junit4 + powermock执行所有测试套件时,我得到一个错误:swt-win32-3650.dll已经加载到另一个类加载器
alltest.java:

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

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

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() );
    }
}


推荐答案

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

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'.

这篇关于当使用junit4 + powermock执行所有测试套件时,我收到一个错误:swt-win32-3650.dll已经加载到另一个类加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆