• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit 4 sampler for JMeter

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As far as I can tell the JUnit Sampler for JMeter only supports JUnit 3, not JUnit 4. The tests I'm trying to repurpose are all JU4 and I don't want to rewrite them in JU3 and have to maintain two test suites. I've tried swapping in the JUnit 4 jar but that didn't help.

Is there a way to use JU4 and JM together?

Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rick,
I haven't used that particular feature, but I can provide a general comment. Do you have the source code for the JUnit Sampler? If so, can you change the line that calls JUnit to use the JUnit 4 Adapter?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone figured this out? I want to use JUnit 4 with Jmeter.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the mail lists, it seems the issue is that jmeter is based on java 1.4 and therefore can't use annotations. I don't think there is a quick fix out of the box. But if you download the code, the method used to find classes that extend TestCase is pretty clever and easy to copy/modify to into a method that finds methods annotated with @Test. I'm not sure how difficult it will be to construct and execute the tests because I haven't gotten that far, yet. Hopefully when I do, I can get it checked-in to a 1.5-specific branch.
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian Sweeney wrote:From the mail lists, it seems the issue is that jmeter is based on java 1.4 and therefore can't use annotations. I don't think there is a quick fix out of the box. But if you download the code, the method used to find classes that extend TestCase is pretty clever and easy to copy/modify to into a method that finds methods annotated with @Test. I'm not sure how difficult it will be to construct and execute the tests because I haven't gotten that far, yet. Hopefully when I do, I can get it checked-in to a 1.5-specific branch.



Yep, it seems that it actually is taking less code to hunt down the @Before and @After annotations and invoke the test method.

And looking for @Test annotations to populate the drop down in the configurator page was not that hard either.

Haven't got it to work completely yet. Can't get all the results to work the way I want. I'll publish the results on my blogg when I do and tell you all.
 
Brian Sweeney
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've posted a patch to jmeter's bugzilla for review. Adoption will probably be slow since it will require a jar change. https://issues.apache.org/bugzilla/show_bug.cgi?id=47803 Download the source, apply the patch, and be on your way. Feedback is more than welcome, especially on the few outstanding issues mentioned in the bug report.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to JMeter's changelog JUnit Sampler started supporting JUnit4-style annotations since version 2.4.

For advanced information on JUnit Request Sampler refer to How to Use JUnit With JMeter guide.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic