Jmeter include controller relative path

荒凉一梦 提交于 2019-12-24 05:22:12

问题


We are using Jmeter-maven-plugin and created a maven project in eclipse. My test file (MainTest.jmx) is in src/test/jmeter folder, in this test we used "include controller" to reuse test fragments. These fragments are stored in src/test/jmeter/fragments. We tried following relative path in include controller

  1. ../fragments/FragmentA.jmx

  2. src/test/jmeter/fragments/FragmentA.jmx

  3. Tried propertiesUser option in pom.xml

<propertiesUser>
                <fragments.directory>src/test/jmeter/fragments</fragments.directory>
</propertiesUser>

Include controller failing to load .jmx file. Getting following

ERROR o.a.j.c.IncludeController: Include Controller 'Include Controller' can't load '${__P(fragments.directory)}/fragmentA.jmx' - see log for details.

java.io.IOException: loadIncludedElements -failed for: E:\Luna\ADXJmeter\target\jmeter\bin\${__P(fragments.directory)}\FragmentA.jmx and E:\Luna\ADXJmeter\target\jmeter\testFiles\${__P(fragments.directory)}\FragmentA.jmx

Complete Log

> 2017-05-24 12:14:39,442 INFO o.a.j.c.IncludeController: loadIncludedElements -- try to load included module: E:\Luna\ADXJmeter\target\jmeter\bin\FragmentA.jmx
> 2017-05-24 12:14:39,442 INFO o.a.j.c.IncludeController: loadIncludedElements -failed for: E:\Luna\ADXJmeter\target\jmeter\bin\FragmentA.jmx
> 2017-05-24 12:14:39,442 INFO o.a.j.c.IncludeController: loadIncludedElements -Attempting to read it from: E:\Luna\ADXJmeter\target\jmeter\testFiles\FragmentA.jmx
> 2017-05-24 12:14:39,442 ERROR o.a.j.c.IncludeController: Include Controller 'Include Controller' can't load 'FragmentA.jmx' - see log for details
> 2017-05-24 12:14:39,443 ERROR o.a.j.u.JMeterUtils: Including file "FragmentA.jmx" failed for Include Controller "Include Controller", unexpected error - see log for details
> 2017-05-24 12:14:39,443 WARN o.a.j.c.IncludeController: Including file "FragmentA.jmx" failed for Include Controller "Include Controller", unexpected error
> java.io.IOException: loadIncludedElements -failed for: E:\Luna\ADXJmeter\target\jmeter\bin\FragmentA.jmx and E:\Luna\ADXJmeter\target\jmeter\testFiles\FragmentA.jmx
>	at org.apache.jmeter.control.IncludeController.loadIncludedElements(IncludeController.java:139) [ApacheJMeter_components-3.2.jar:3.2 r1790748]
>	at org.apache.jmeter.control.IncludeController.resolveReplacementSubTree(IncludeController.java:111) [ApacheJMeter_components-3.2.jar:3.2 r1790748]
>	at org.apache.jmeter.JMeter.runNonGui(JMeter.java:936) [ApacheJMeter_core-3.2.jar:3.2 r1790748]
>	at org.apache.jmeter.JMeter.startNonGui(JMeter.java:910) [ApacheJMeter_core-3.2.jar:3.2 r1790748]
>	at org.apache.jmeter.JMeter.start(JMeter.java:538) [ApacheJMeter_core-3.2.jar:3.2 r1790748]
>	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
>	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
>	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]

回答1:


Have you read the documentation prior to attempting to use Include Controller this way?

This element does not support variables/functions in the filename field. However, if the property includecontroller.prefix is defined, the contents are used to prefix the pathname.

The same chapter provides the clue: you have includecontroller.prefix property and JMeter will attempt to find the file under the path of includecontroller.prefix + Filename

So you should amend your configuration as follows:

<propertiesUser>                
    <includecontroller.prefix>src/test/jmeter/fragments</includecontroller.prefix>
</propertiesUser>

And use just FragmentA.jmx in the Include Controller.

Check out How to Manage Large JMeter Scripts With JMeter Test Fragments for more information on working with modular JMeter tests.



来源:https://stackoverflow.com/questions/44133553/jmeter-include-controller-relative-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!