Prathyush created SUREFIRE-1511:
-----------------------------------
Summary: Surefire java.lang.ClassFormatError error when running
powermockito textNg tests
Key: SUREFIRE-1511
URL: https://issues.apache.org/jira/browse/SUREFIRE-1511
Project: Maven Surefire
Issue Type: Bug
Affects Versions: 2.21.0
Reporter: Prathyush
powermock-version : 1.6.6
mockito-version : 2.0.2-beta
maven-surefire-plugin version : 2.20.1
When running tests using below profile am getting below exception
*Profile :*
<profile>
<id>sonar-coverage</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/DocGenDistBusinessServiceImplTest.java</exclude>
<exclude>**/TeamworksStipulationCreationListenerImplTest.java</exclude>
<exclude>**/UpdateClosingFeeStateListenerTest.java</exclude>
<exclude>**/SubscribeEvent.java</exclude>
<exclude>**/PublishEvent.java</exclude>
<exclude>**/ECBSHelper_Test.java</exclude>
<exclude>**/StipulationImageAssociationServiceRPCMilestoneTest.java</exclude>
</excludes>
<argLine>-Xms512m -Xmx10648m ${argLine}
-javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar</argLine>
<properties>
<property>
<name>listener</name>
<value>com.wellsfargo.core.common.dp.testng.LogTestListener</value>
</property>
</properties>
<runOrder>random</runOrder>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent-for-ut</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>agent-for-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>4.15.0.12310</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.7.9</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
*Exception:*
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class
com.wellsfargo.core.business.service.dp.applicationManagement.hmda.reportableData.field.handler.BaseHmdaFieldGetterBusinessHierarchy$$EnhancerByMockitoWithCGLIB$$6b2b5065
Mockito can only mock visible & non-final classes.
If you're not sure why you're getting this error, please report to the mailing
list.
at
org.powermock.api.extension.listener.AnnotationEnabler.injectSpiesAndInjectToSetters(AnnotationEnabler.java:72)
at
org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.powermock.reflect.internal.WhiteboxImpl.performMethodInvocation(WhiteboxImpl.java:1819)
at
org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:691)
at org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:415)
at
org.powermock.modules.testng.PowerMockTestCase.injectMocks(PowerMockTestCase.java:165)
at
org.powermock.modules.testng.PowerMockTestCase.beforePowerMockTestMethod(PowerMockTestCase.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135)
at
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:112)
at
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
at
org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:146)
at
org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373)
at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407)
Caused by: org.mockito.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at
org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:238)
at org.mockito.cglib.proxy.Enhancer.createHelper(Enhancer.java:378)
at org.mockito.cglib.proxy.Enhancer.createClass(Enhancer.java:318)
at
org.powermock.api.mockito.repackaged.ClassImposterizer.createProxyClass(ClassImposterizer.java:124)
at
org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:58)
at
org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMethodInvocationControl(DefaultMockCreator.java:121)
at
org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMock(DefaultMockCreator.java:69)
at
org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.mock(DefaultMockCreator.java:46)
at org.powermock.api.mockito.PowerMockito.spy(PowerMockito.java:221)
at
org.powermock.api.mockito.internal.configuration.PowerMockitoSpyAnnotationEngine.process(PowerMockitoSpyAnnotationEngine.java:57)
at
org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine.process(PowerMockitoInjectingAnnotationEngine.java:32)
... 42 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mockito.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:385)
at
org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
... 52 more
Caused by: java.lang.ClassFormatError: Duplicate method name&signature in
class file
com/wellsfargo/core/business/service/dp/applicationManagement/hmda/reportableData/field/handler/BaseHmdaFieldGetterBusinessHierarchy$$EnhancerByMockitoWithCGLIB$$6b2b5065$$EnhancerByMockitoWithCGLIB$$c059fc87
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
... 57 more
Please help. We stuck on this issue.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)