You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Chamara Ariyarathne <ch...@wso2.com> on 2017/11/08 02:28:59 UTC

Fwd: Trying to run a jmeter script through a testng Test and fails

Hi all,

I'm trying to run a jmeter script with the following Test method in testng
and my maven build fails like following. Any help in resolving this matter
will be appreciated.

*Method: *

    @Test
    public void runJmeter() throws Exception {
        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        JMeterUtils.setJMeterHome("/home/chamara/Programs/apache-jmeter-3.2
");
        JMeterUtils.loadJMeterProperties("/home/
chamara/stress-test-framework/src/test/resources/CUSTOM/user.properties");
        JMeterUtils.initLogging();
        JMeterUtils.initLocale();

        SaveService.loadProperties();

        FileInputStream in = new FileInputStream("/home/
chamara/stress-test-framework/src/test/jmeter/CUSTOM/
Concurrency_Thread_Group.jmx");
        HashTree testPlanTree = SaveService.loadTree(in);
        in.close();

        jmeter.configure(testPlanTree);
        jmeter.run();


    }

*Failure: *

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.wso2.stress.StressTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.
TestNG652Configurator@2db0f6b2
INFO    2017-11-07 18:35:18.029 [jmeter.e] (): Listeners will be started
after enabling running version
INFO    2017-11-07 18:35:18.041 [jmeter.e] (): To revert to the earlier
behaviour, define jmeterengine.startlistenerslater=false
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.389 sec
<<< FAILURE!
runJmeter(org.wso2.stress.StressTest)  Time elapsed: 0.199 sec  <<< FAILURE!
java.lang.NullPointerException
at org.apache.jmeter.engine.StandardJMeterEngine.configure(
StandardJMeterEngine.java:164)
at org.wso2.stress.StressTest.runJmeter(StressTest.java:31)


-- 
*Chamara Ariyarathne*
WSO2 Inc; http://www.wso2.com/
Mobile; *+94772786766 <077%20278%206766>*

Re: Trying to run a jmeter script through a testng Test and fails

Posted by jmeter tea <jm...@gmail.com>.
It seems that you have extra sapces in path: ("/home/
chamara/stress-test-framework/src/test/jmeter/CUSTOM/
Concurrency_Thread_Group.jmx");

Try with ("/home/chamara/stress-test-framework/src/test/jmeter/CUSTOM/
Concurrency_Thread_Group.jmx");

On Wed, Nov 8, 2017 at 4:28 AM, Chamara Ariyarathne <ch...@wso2.com>
wrote:

> Hi all,
>
> I'm trying to run a jmeter script with the following Test method in testng
> and my maven build fails like following. Any help in resolving this matter
> will be appreciated.
>
> *Method: *
>
>     @Test
>     public void runJmeter() throws Exception {
>         StandardJMeterEngine jmeter = new StandardJMeterEngine();
>
>         JMeterUtils.setJMeterHome("/home/chamara/Programs/apache-
> jmeter-3.2
> ");
>         JMeterUtils.loadJMeterProperties("/home/
> chamara/stress-test-framework/src/test/resources/CUSTOM/user.properties");
>         JMeterUtils.initLogging();
>         JMeterUtils.initLocale();
>
>         SaveService.loadProperties();
>
>         FileInputStream in = new FileInputStream("/home/
> chamara/stress-test-framework/src/test/jmeter/CUSTOM/
> Concurrency_Thread_Group.jmx");
>         HashTree testPlanTree = SaveService.loadTree(in);
>         in.close();
>
>         jmeter.configure(testPlanTree);
>         jmeter.run();
>
>
>     }
>
> *Failure: *
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running org.wso2.stress.StressTest
> Configuring TestNG with: org.apache.maven.surefire.testng.conf.
> TestNG652Configurator@2db0f6b2
> INFO    2017-11-07 18:35:18.029 [jmeter.e] (): Listeners will be started
> after enabling running version
> INFO    2017-11-07 18:35:18.041 [jmeter.e] (): To revert to the earlier
> behaviour, define jmeterengine.startlistenerslater=false
> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.389 sec
> <<< FAILURE!
> runJmeter(org.wso2.stress.StressTest)  Time elapsed: 0.199 sec  <<<
> FAILURE!
> java.lang.NullPointerException
> at org.apache.jmeter.engine.StandardJMeterEngine.configure(
> StandardJMeterEngine.java:164)
> at org.wso2.stress.StressTest.runJmeter(StressTest.java:31)
>
>
> --
> *Chamara Ariyarathne*
> WSO2 Inc; http://www.wso2.com/
> Mobile; *+94772786766 <077%20278%206766>*
>