I've implemented a testing unit using spring (mock mvc), and I'm looking for a tool to run this unit in many threads/processes (so it will act as load testing for my server). I've seen applications like the grinder and jmeter but I don't want to re-write the entire unit, but just to use the existing one. Any ideas?
Asked
Active
Viewed 5,809 times
1 Answers
1
JMeter is able to execute existing JUnit tests via JUnit Request sampler, all you need to do is to drop jar(s) with your test along with dependencies somewhere in JMeter classpath and restart JMeter. Once done you'll be able to see your classes and methods in JUnit Request sampler dropdown and execute them in multithreaded manner.
See How to Use JUnit With JMeter guide for more detailed instructions and explanations.

Dmitri T
- 159,985
- 5
- 83
- 133
-
Thanks! I'm trying to make it work but it seems like Jmeter doesn't recognize my junit jar. If I put it under /lib or /lib/junit then an error is thrown: ERROR - jmeter.JMeter: Uncaught exception: java.lang.NoClassDefFoundError: Could not initialize class org.apache.jmeter.gui.util.MenuFactory and the edit menu is grayed out . If I'm adding it to the user.properties : user.classpath=C:\...\tests.jar, then it is not shown under the JUnit Request classname dropdown menu(even if the search for junit4 annotation is checked). Any ideas? – user_s Oct 06 '15 at 11:52
-
Maybe it's due to libraries clash, like dependencies of your test.jar conflict with jars which live under JMeter's /lib folder. – Dmitri T Oct 06 '15 at 11:54
-
When I'm removing almost all dependencies, the menu is no longer grayed out (and the error is not thrown) but it is still not showing up on the JUnit Request classname dropdown menu – user_s Oct 06 '15 at 12:24
-
Ok so the problems were : 1) it clashed with log4j and 2) I needed to add All tests (Intellij - right click on the test src folder), for some reason the main class I provided wasn't enough. Also mark include tests when creating the jar. It is still not working (it fails on tests that works normally without any information), but I will keep digging into that. Thanks a lot. – user_s Oct 06 '15 at 13:57
-
have you resolved the issue? maybe spring boot doesn't work with JMeter? – Hasson Apr 24 '17 at 21:45