How to add classpath for jmeter test ?

3,400 views
Skip to first unread message

nabedge

unread,
Mar 18, 2012, 11:06:33 AM3/18/12
to maven-jmeter...@googlegroups.com
Hi.
I'm trying to run jmeter test with jmeter-maven-plugin.

I wrote the code for performance test as JUnit4 testcase.
-> src/test/org/jmeter/xhtml/PerfTest.java

And I wrote src/test/jmeter/perfomanceTest.jmx like below.

<stringProp
name="junitSampler.classname">org.mixer2.xhtml.PerfTest</stringProp>
<stringProp name="junitsampler.method">loadTemplateTest</stringProp>

I ran mvn jmeter:jmete, but I got error.

ERROR - jmeter.JMeter: Error in NonGUIDriver
java.lang.RuntimeException: Could not find the TestPlan class!

I understand that my testcase class is not on classpath of
jmeter-maven-plugin running.

What is the best way to add my junit4 testcase code to classpath of jmeter ?

--
nabedge
Tokyo, Japan
http://twitter.com/nabedge

Arne Franken

unread,
Mar 18, 2012, 7:34:53 PM3/18/12
to maven-jmeter...@googlegroups.com
Hi,

just include the jar with your custom classes as a plugin dependency. Mark explained here how this works:

https://groups.google.com/d/topic/maven-jmeter-plugin-users/dzwd03tO3cg/discussion

Cheers,
Arne

nabedge

unread,
Mar 19, 2012, 12:01:38 AM3/19/12
to maven-jmeter...@googlegroups.com
Arne, thank you for your reply.

Hmm... I understand what you saying.

I write Junit4 testcase and run it with mvn jmeter:jmeter,
next, I re-write testcase and run jmeter:jmeter... again and again....
In this process, I have to "mvn package" my real code and testcase
classes to jar file and "mvn install".

But I'm looking for more convenient methodology.

For example, We can use maven classpath reference with maven-antrun-plugin.
http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

Does anybody have idea to do something similer ?
--
http://twitter.com/nabedge


2012/3/19 Arne Franken <arne.f...@googlemail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "Maven JMeter Plugin Users" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/maven-jmeter-plugin-users/-/npX3xaMua4UJ.
> To post to this group, send an email to
> maven-jmeter...@googlegroups.com.
> To unsubscribe from this group, send email to
> maven-jmeter-plugi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/maven-jmeter-plugin-users?hl=en-GB.

Mark Collin

unread,
Mar 19, 2012, 2:29:51 AM3/19/12
to maven-jmeter...@googlegroups.com
Right now that's the only way.

If you want to be able to add to the classpath you would need to add a
feature request to https://github.com/Ronnie76er/jmeter-maven-plugin/issues.


You will never be able to overwrite the classpath because we build it up
when initializing the plugin to make sure that JMeter has access to all of
its libraries, overwriting it could break quite a few things.

nabedge

unread,
Mar 19, 2012, 3:57:47 AM3/19/12
to maven-jmeter...@googlegroups.com
Thank you, Mark.
I understand for this problem. thanks!

2012/3/19 Mark Collin <mark....@lazeryattack.com>:

--
わたなべ
http://twitter.com/nabedge

Arne Franken

unread,
Mar 20, 2012, 4:56:02 AM3/20/12
to maven-jmeter...@googlegroups.com
Hi,

I write Junit4 testcase and run it with mvn jmeter:jmeter,
next, I re-write testcase and run jmeter:jmeter... again and again....
In this process, I have to "mvn package" my real code and testcase
classes to jar file and "mvn install".

that's how maven works...
If you work with different workspaces or different modules, you'll have to build them all in order to have the latest code.

say, you have this module structure:

performance-tests/
performance-tests/custom-code/
performance-tests/jmeter-test/

where your code is in the custom-code module and is built to a jar and the jmeter test configuration (along with a dependency on custom-code) is in jmeter-tests, you can just go to performance-tests and run
mvn -am -pl jmeter-test clean install
Maven will go ahead, look in to the POM in performance-tests, see that there are two sub-modules and one depends on the other, and build both in the right order, the jmeter test will also be run.

No need to add a separate plugin property that is not really needed and needs code that we have to maintain for years...

Cheers,
Arne


> To unsubscribe from this group, send email to

Reply all
Reply to author
Forward
0 new messages