Pax-Exam issue with TestNG Integration -
i tried integrate pax-exam plugin testng , ended getting following error. working fine junit.
[org.ops4j.pax.exam.spi.intern.defaulttestaddress] : new address= paxexam-90b1718e-7414-486a-8ae2-b5628e4b7a67 parent=[testaddress:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99 root:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99] root=[testaddress:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99 root:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99] args=[ljava.lang.object;@4f063c0a [org.ops4j.pax.exam.spi.intern.defaulttestaddress] : new address= paxexam-652d3b11-ab7c-49d0-bcba-f9d56c9210ee parent=[testaddress:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855 root:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855] root=[testaddress:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855 root:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855] args=[ljava.lang.object;@1e6d1014 org.apache.maven.surefire.util.surefirereflectionexception: java.lang.reflect.invocationtargetexception; nested exception java.lang.reflect.invocationtargetexception: null java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.apache.maven.surefire.util.reflectionutils.invokemethodwitharray(reflectionutils.java:189) @ org.apache.maven.surefire.booter.providerfactory$providerproxy.invoke(providerfactory.java:165) @ org.apache.maven.surefire.booter.providerfactory.invokeprovider(providerfactory.java:85) @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:103) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:74) caused by: java.lang.nosuchmethoderror: org.testng.internal.methodinstance.<init>(lorg/testng/itestngmethod;)v @ org.ops4j.pax.exam.testng.listener.paxexam.intercept(paxexam.java:503) @ org.testng.testrunner.createparallelworkers(testrunner.java:995) @ org.testng.testrunner.privaterun(testrunner.java:747) @ org.testng.testrunner.run(testrunner.java:608) @ org.testng.suiterunner.runtest(suiterunner.java:334) @ org.testng.suiterunner.runsequentially(suiterunner.java:329) @ org.testng.suiterunner.privaterun(suiterunner.java:291) @ org.testng.suiterunner.run(suiterunner.java:240) @ org.testng.suiterunnerworker.runsuite(suiterunnerworker.java:52) @ org.testng.suiterunnerworker.run(suiterunnerworker.java:86) @ org.testng.testng.runsuitessequentially(testng.java:1158) @ org.testng.testng.runsuiteslocally(testng.java:1083) @ org.testng.testng.run(testng.java:999) @ org.apache.maven.surefire.testng.testngexecutor.run(testngexecutor.java:76) @ org.apache.maven.surefire.testng.testngdirectorytestsuite.execute(testngdirectorytestsuite.java:112) @ org.apache.maven.surefire.testng.testngprovider.invoke(testngprovider.java:115) ... 9 more
any idea went wrong here?.
following sample test code. think basic test-case can write.
import org.ops4j.pax.exam.configuration; import org.ops4j.pax.exam.option; import org.ops4j.pax.exam.spi.reactors.examreactorstrategy; import org.ops4j.pax.exam.spi.reactors.perclass; import org.ops4j.pax.exam.testng.listener.paxexam; import org.osgi.framework.bundlecontext; import org.testng.annotations.listeners; import org.testng.annotations.test; import javax.inject.inject; import static org.testng.assert.assertnotnull; import static org.ops4j.pax.exam.coreoptions.*; @listeners(paxexam.class) @examreactorstrategy(perclass.class) public class sampletest { @inject bundlecontext bundlecontext; @configuration public option[] config() { return options( mavenbundle().artifactid("testng").groupid("org.testng").versionasinproject() ); } @test public void testbundlecontextstatus() { assertnotnull(bundlecontext, "bundle context null"); } }
here dependencies i've used.
<dependency> <groupid>org.testng</groupid> <artifactid>testng</artifactid> <version>${testng.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ops4j.pax.exam</groupid> <artifactid>pax-exam</artifactid> <version>${exam.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ops4j.pax.exam</groupid> <artifactid>pax-exam-container-native</artifactid> <version>${exam.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ops4j.pax.exam</groupid> <artifactid>pax-exam-testng</artifactid> <version>${exam.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ops4j.pax.exam</groupid> <artifactid>pax-exam-link-mvn</artifactid> <version>${exam.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ops4j.pax.url</groupid> <artifactid>pax-url-aether</artifactid> <version>${url.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>${slf4j.api.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.ow2.spec.ee</groupid> <artifactid>ow2-jta-1.1-spec</artifactid> <version>${ow2.jta.spec.version}</version> <scope>test</scope> </dependency>
after changing testng depenedncy version 6.3.1 worked correctly. latest released version 6.9.6 issue there.
the latest edit question contains answer. pax exam 4.6.0 compiled testng 6.8.17, , apparently there has been incompatible api change in testng 6.9.x.
pax exam directly uses internal classes of testng lack of better alternative.
you're better off using pax exam junit in general. junit better integrated , has lot more test coverage , usage in ops4j , other downstream projects.
Comments
Post a Comment