I'm using beanshell postprocessor to write a file in my jmeter script,when I run this script as a maven project the file is being written into the
target folder. I want it to be written inside the src/test/jmeter of my project. How can I achieve this. I'm new in my testing journey so if you find my question silly spare and help me
I tried using the userpropertiesin my pom.xml, also I tried using the maven resource plugin to copy the file from Target to src/test/jmeter.
Edit:
I have created a folder structure like
src/test/jmeter/test_folder/test file.csv
src/test/jmeter/test_folder/testplan.jmx
When I try to add the testfile.csv as a input by using csvdatasetconfig element,by giving the relative address as ./testfile.csv
,the test plan works inside the jmeter ui,but when i it run from my maven project the testfile.csv
is not found.
JMeter Maven Plugin sets JMeter basedir / working directory to a very specific location, you can determine it from jmeter.log file
2023-10-11 16:58:47,475 INFO o.a.j.JMeter: user.dir =/path/to/your/project/target/some-guid/jmeter/bin
so you need to get 4 levels up in order to get to your project directory and then navigate to target directory.
Instead of:
new File("somefile.txt")
you need to use a relative path, something like:
new File("../../../../src/test/jmeter/somefile.txt")
In general your approach seems not too good to me: