Forum Discussion

roryLIT's avatar
roryLIT
Contributor
12 years ago

Only letting an external file be accessed by one testcase

I have a testsuite of 60 testcases and an external text file with a list of values. I want to run the testcases concurrently. Each testcase will access this file and take a value from the file to use in the test. The issue I'm having is more than 1 test is taking the same value because they are accessing the file at the same time (the same value can't be used in more than 1 test at the same time). I need a way where the file can only be accessed by one testcase at a time. Any ideas for what I could write in Groovy for this? I would use this groovy script at the start of each testcase
  • SiKing's avatar
    SiKing
    Community Expert
    roryLIT wrote:
    ... I want to run the testcases concurrently. Each testcase will access this file and take a value from the file to use in the test. The issue I'm having is more than 1 test is taking the same value because they are accessing the file at the same time ...

    Can you please explain this? If the tests are running concurrently, how can multiple test cases be accessing the file at the same time?
  • So when I kick off the testsuite to run the tests in parallel I would have a groovy script at the start of each testcase which would access the file and get a value for the test but because the tests all kick off so quickly the external file is being read by multiple tests at the exact same time resulting in the same value being read and used in multiple tests. Is there any way to prevent the testcases accessing the file at the same time? Some kind of lock?
  • SiKing's avatar
    SiKing
    Community Expert
    roryLIT wrote:
    So when I kick off the testsuite to run the tests in parallel ...

    Oh, so the suite is not sequential and we are talking about a completely different problem!

    Have a read through this http://siking.wordpress.com/2013/11/01/ ... th-soapui/ You are probably interested in the last case that describes the SoapUI monitor.

    Good luck.