0
<testcase time="0.593" classname="org.apache.maven.surefire.junit4.JUnit4Provider" name="facade.FacadeBeanTest">
    <error message="Failed to transform class with name BusinessServiceImpl. Reason: NameKeyList" type="java.lang.IllegalStateException">java.lang.IllegalStateException: Failed to transform class with name BusinessServiceImpl. Reason: NameKeyList
    at javassist.ClassPool.get(ClassPool.java:450)
    at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:592)
    at javassist.bytecode.Descriptor.getReturnType(Descriptor.java:489)
    at javassist.CtBehavior.getReturnType0(CtBehavior.java:306)
    at javassist.CtMethod.getReturnType(CtMethod.java:217)
    at org.powermock.core.transformers.impl.MainMockTransformer.modifyMethod(MainMockTransformer.java:172)
    at org.powermock.core.transformers.impl.MainMockTransformer.allowMockingOfStaticAndFinalAndNativeMethods(MainMockTransformer.java:142)
    at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:65)
    at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:215)
    at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:147)
    at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:95)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
    at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:370)
    at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:351)
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
    at java.lang.Class.getAnnotations(Class.java:3050)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.classAnnotations(PowerMockJUnit44RunnerDelegateImpl.java:163)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.getDescription(PowerMockJUnit44RunnerDelegateImpl.java:155)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.getDescription(JUnit4TestSuiteChunkerImpl.java:171)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.getDescription(AbstractCommonPowerMockRunner.java:47)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:51)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    </error>
</testcase>

@Test
public void createRegistrationTest() {
    try {
        RegistrationResponse response = facadeBeanTest.createAegistration(RegistrationFacadeMock.getCreateRegistrationRequest());
        Assert.assertEquals(true, response.isRegistrationSuccessful());
    } catch (Exception e) {
        Assert.fail("Exception occured : " + e);
    }

}

テスト ケースは完全な成功を返し、期待される結果を返します。プロジェクトをビルドしているときに、testsuite xml で例外を取得し、ビルドに失敗しました。任意のアイデア、mockit または powermock のバージョンを見逃しましたか?

Pom.xml

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.10.8</version>
    <scope>test</scope>
</dependency>
<dependency>
   <groupId>org.powermock</groupId>
   <artifactId>powermock-module-junit4</artifactId>
   <version>1.5.1</version>
   <scope>test</scope>
</dependency>
<dependency>
   <groupId>org.powermock</groupId>
   <artifactId>powermock-api-mockito</artifactId>
   <version>1.5.1</version>
   <scope>test</scope>
</dependency>

BsuinessServiceImpl.java の下には多くのメソッドがあり、テスト メソッドで呼び出された createRegistration() のみが成功を返しました。

public createRegistration(){
ammoRegistrationPeristenceImpl.create(ammoRegistrationPO);
}

protected NameKeyList generateNameKeys(Name name) throws Exception {
try {
    return searchUtil.getRemote().getNameKeys(name);
} catch (RemoteException e) {

}
}
4

0 に答える 0