Forum Discussion

Jovan_Kubicek's avatar
16 years ago

Any way to have opened FileReader object during whole loadtest?

I'd like to have data driven load test in non-pro version.
So I don't have datasources as an option, i'd like to open file and set the properities for each test case cycle, parsing the csv file (each line for one cycle). Because the file is realy big, i dont like, to skip the lines to the position of actual step in each cycle (it wouln't be able to provide adequate load).

Other way to success, is to open file and store it in object collection on higher level. But not shure how to access such object from grooovy scripts on test steps level..

Am I right?

Thanx Lot... for any advices

1 Reply

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    Try the following:

    - create the FileWriter in the LoadTest setup script and save it to the context;

    context.myWriter = new FileWriter( .. )

    - access it from a groovy script in your testcase with

    def writer = context.LoadTestContext.myWriter

    -> since the LoadTestContext will be null when running the TestCase standalone, you will need to check for this
    -> also, you might want to synchronize access to the writer

    - close the writer in the LoadTest TearDown script..

    hope this helps!

    regards,

    /Ole
    eviware.com