Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

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

  • omatzura's avatar
    omatzura
    Super Contributor
    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
  • alibaba82's avatar
    alibaba82
    Super Contributor
    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
  • omatzura's avatar
    omatzura
    Super Contributor
    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