0
votes

I am trying to call a Test fragment which consists of reusable sampler. I want to call the test fragment in my other script using Include controller, I want to achieve this by giving relative path in include controller, It is working when absolute path of the test fragment is set but gives an error if provided with relative path.

Below path I have set in user defined variable: (folder structure is based on Maven project)

../../../src/test/resources/testData

Below is the error which I get: enter image description here

Below is the path I have set in user defined variable config for Test Fragment: enter image description here

Below is the image of Include controller in which i am trying to call the test fragment using relative/dynamic path: enter image description here

2
Do you try remove space in Login TestFragment.jmx?lojza
Yes, it is the same file name which I gave earlier, Now I have the file name in proper camel case but still facing the issue.Nahor

2 Answers

1
votes

According to the Include Controller documentation:

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.

So you have the following workarounds:

  1. Consider embedding the external .jmx file into the main one using Module Controller
  2. Or run your "included" script as a separate process using OS Process Sampler, the .jtl results file can be combined with the "parent" result file via Merge Results tool
0
votes

TLDR;

ForEach Controller(testFragmentName) -> Switch Controller(testFragmentName) -> [IncludeController1(existingPath1),IncludeController2(existingPath2)]

Intro & my data

So... I've been researching the subject and didn't like any proposed solutions as I want to have full control of the project.

My idea is to have suites defined in json like:

{
    "Suites": [
        {
            "name": "ExampleTest",
            "testFragments": [
                "Login",
                "HomePage",
                "Logout"
            ]
        }
    ]
}

Having defined the test and it's modules I go to selected test plan.

Test plan elements, main points

Used HTTP Request with file protocol to get json file with data to extract:
enter image description here

Property/variable input: suites
Json Path: $.Suites[?(@.name in [${suites}])].testFragments.*

Now I prepare such test structure:
| ForEach
| - Switch
| - - Include1
| - - Include2
...

ForEach Controller
ForEach
Switch Controller
Switch

Include Controllers
The only thing left to do is define every Include Controller with existing path name so error doesn't occure. I don't suggest using includecontroller.prefix as it's pretty much useless.

The whole operation requires defining all external jmx test fragments within the switch controller as Include Controllers with correct names (switch controllers needs to know which controller to chose).

Conclusion

In my opinion it's worth as you can use external properties ('suites' or other as you would like) to run predefined suites.

It's not perfect but it allows complete modularization and external control via simple property input.

PS. Include Controller is obviously a strong contender for the worst design of functionality ever.