cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically changing Datasource file

Highlighted
Super Contributor

Dynamically changing Datasource file

Hello,
I am running a load test with 5 threads. I have 5 external text files Which contain data for my requests.

I want thread0 to access file0.txt, thread1 to access file1.txt ... and so on. Is it possible to write some groovy script before the datasource step that will modify the File location for each thread's context so that the datasource in thread0 will be c:\...\file0.txt etc etc

Thanks

Ali
5 REPLIES 5
Highlighted
Super Contributor

Re: Dynamically changing Datasource file

Any suggestion / updates on this issue ?
Highlighted
Super Contributor

Re: Dynamically changing Datasource file

Hi Ali,

sorry for the delayed replay.. have you tried setting the filename to something like

c:\data\file${context.ThreadIndex}.txt

?

regards,

/Ole
eviware.com
Highlighted
Super Contributor

Re: Dynamically changing Datasource file

Ole,
This does not seems to work. I get the following error.

Test failed [java.io.FileNotFoundException: C:\Workspace\QA\Automation\soapUI_Scripts\Phase2\DataFiles\Email${context.ThreadIndex}.txt (The system cannot find the file specified)], time taken = 1006
Highlighted
Super Contributor

Re: Dynamically changing Datasource file

Sorry Ali, my fault.. it should have been just

c:\data\file${ThreadIndex}.txt

but I also found a bug so that the above will only work when running the entire TestCase and not when running with the "Test" button in the DataSource window.. will be fixed in the next snapshot..

regards!

/Ole
eviware.com
Highlighted
Super Contributor

Re: Dynamically changing Datasource file

Thanks for you help Ole. This works perfectly now.
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite
Top Kudoed Authors