Reputation: 145
I am working on performance testing a command line tool. I already have an integration test written using Junit that tests the entirety of the command line tool and I'd like to reuse it for monitoring performance.
I am using the JUnit Request Sampler but it is unable to start the test because of the error.
2016/05/18 16:22:36 INFO - jmeter.protocol.java.sampler.JUnitSampler: Trying to find constructor with one String parameter returned error: org.someorg.integration.IntegrationTest.<init>(java.lang.String)
I saw this and I don't have a setUp or a tearDown in my tests. Thoughts on what I maybe missing?
Upvotes: 0
Views: 3546
Reputation: 63
I was facing same issue and after trying many solutions things didn't work. Things started to work after giving unique name to JUnit samplers. I have 100 JUnit samplers and didn't cause any problem after using unique names to sampler.
You don't have to add constructor to your Test class. Giving Unique name to sampler is good enough.
Upvotes: 0
Reputation: 4274
I had the same problem. I resolved it with two constructors:
Like this:
public MyTestClass() {
// Do nothing
}
public MyTestClass(String test) {
this();
}
JMeter stopped complaining after this. A bit weird, but if it works... As a side effect, the test would not run in eclipse anymore, so I created two versions of the test class:
Upvotes: 2
Reputation: 168092
As per How to Use JUnit With JMeter guide:
Constructor String Label
If your JUnit test class has a constructor which accepts a single String, you can set its value with this parameter. If your JUnit test class doesn’t declare such a constructor, the JUnit Sample will try to look for an empty constructor.
So you have 2 options:
If one of above conditions is met - JMeter will be able to run your class.
See Providing Constructors for Your Classes guide for explanation of the "constructor" bit.
Upvotes: 0