Forum Discussion

SiKing's avatar
SiKing
Community Hero
13 years ago

DataSource: Goto Loop on Empty

I have a Groovy DataSource that I am struggling with.

I need to generate all possible locales. I used the following script in the DataSource:
def row = testRunner.testCase.testSteps["generate Locales"].currentRow
result["oneLocale"] = Locale.availableLocales[row].toString()

However, our application does not support any locales that do not follow the xx_YY format; Java 7 has like 8 or something that do not. So I added the following to my script:
if(result["oneLocale"].size() > 5)
result["oneLocale"] = ""

and I checked the "Goto Loop on Empty" in the Options. The test still runs through the (now) empty ones. I also tried:
if(result["oneLocale"].size() > 5)
result["oneLocale"] = null

still same problem. I also tried:
if(result["oneLocale"].size() > 5)
testRunner.gotoStepByName("next Locale") // corresponding DataSourceLoop

still same problem.

What is the "Goto Loop on Empty" option suppose to do?

4 Replies

  • SiKing's avatar
    SiKing
    Community Hero
    The description there says:
    If the DataSource is empty on initial execution, this option will transfer TestCase execution to the first matching DataSourceLoop step after the DataSource in the TestCase
    (emphasis mine) That seems to suggest that only if there is no data at the start of the loop, it will jump to the DataSourceLoop. Is that correct?

    Why does the
    if(result["oneLocale"].size() > 5)
    testRunner.gotoStepByName("next Locale") // corresponding DataSourceLoop
    not work in the DataSource?
  • Hi,

    Sorry for the slow response. Your last presumption presumption is correct - "Go to loop on empty" makes the test case jump to the datasource loop only when the datasource contains no data whatsoever, so I don't think this option is what you're looking for in your use case.

    As for why your script isn't working, I'm not sure; I got a similar scenario working just fine (I've attached the project). If you could attach your project file I would happily take a look.

    Otherwise, if I've misunderstood something, please let me know.

    Regards,
    Arian
    SmartBear Sweden