Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clover instrumented tests with JUnit @Parameterized are failing with NoClassDefFound: junit/runner/TestRunListener

Deleted user Nov 12, 2015

I managed to build our tests with help of this tutorial https://confluence.atlassian.com/display/CLOVER/Using+Clover+with+Maven+Tycho+Plugin, coverage data is generated, but there is one small problem:

All tests that are being run with @Parameterized annotation are failing with

java.lang.NoClassDefFound: junit/runner/TestRunListener

 

From what I've found so far the exception is comming from JUnitParameterizedTestSniffer that is injected by clover.

Do you have any idea how to fix this?

2 answers

0 votes

Hi Ola,

If Clover detects JUnit parameterized test, it adds an extra static field which is being used to record test iterations. The JUnitParameterizedTestSniffer uses junit.runner.TestRunListener, which is a class from the JUnit JAR. Normally, it should work out of the box, as if you're running a JUnit test you also must have a junit.jar in a classpath.

1) Could you please tell us what version of JUnit do you use?

2) Do you have junit.jar in the test classpath when running tests?

Cheers
Marek 

Deleted user Nov 13, 2015

Hi Marek,

 

I forgot to mention what versions we are using, sorry for that. We're using maven3, tycho 0.22, junit 4.11.

I am pretty sure that junit is in the classpath. When I run mvn clean install -e -X in our tests directory I have this in logs:

[DEBUG] Using test framework provider org.eclipse.tycho.surefire.provider.impl.JUnit4Provider 
[DEBUG] Installation OSGI bundles: 
...

[DEBUG]     reference:file:C:/Users/User/.m2/repository/p2/osgi/bundle/org.junit/4.11.0.v201303080030/org.junit-4.11.0.v201303080030.jar 

...

I've also tried to push junit in using -Xbootclasspath/a: but with no luck.

 

Only thing that comes to my mind is that clover is using different class loader somehow.

 

I think it's highly probable that JUnit and Clover are loaded by different class loaders (Clover from basic bootstrap, JUnit by OSGI Class loader) If you add JUnit to boot classpath you'll probably end up with 2 Junit libraries in the JVM and it's not working well as-well. Have you tried simply adding Clover as an maven dependency to test module? I suspect {{-Xbootclasspath}} won't be necessary in that case.

Feel free to raise a ticket at support.atlassian.com (providing build logs, build files etc).

Deleted user Nov 17, 2015

@Grzegorz Lewandowski Yes, tried that, nothing changed. Do you know any way to force clover into same class loader? I guess that if every test bundle has dependency to clover (transformed into osgi bundle) it might work. I will try that tomorrow. @Marek Parfianowicz If I don't succeed I will raise a ticket for sure! I will try to make some kind of smallest "working" example.

0 votes
Deleted user Nov 26, 2015

Finally I've solved this problem using this piece of code after instrumentation:

<replace dir="${project.instrumented.dir}" token="new com_atlassian_clover.JUnitParameterizedTestSniffer()" value="com_atlassian_clover.TestNameSniffer.NULL_INSTANCE"> 
	<include name="**/*.java"/> 
</replace>

 

Maybe it is not the prettiest solution - but it works just fine.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

10 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you