Forum Discussion

DLuks's avatar
DLuks
Contributor
13 years ago

Testcase: Datasource, TestRequest, Dataloop - Test Vars?

Hey forum,

I have a Testcase that pulls data from an Excel sheet, is setup with a Test Request, and runs the dataloop. My datasource also has a column with a distinct string 'variable name' to be used as a reference for later dataloops within the datasource.

Basically the output of each loop, sets context['variable name'] = the hit count of results.

Everything works fine within the client. The variables are kept intact, equations are stringed together and I have a JavaScript math evaluator performing assertions.

We have this process also running with Maven on our Hudson build server. Maven has a soap-ui-pro plugin that it can use to execute these test cases.

The problem seems to be because of a null object in the Javascript eval funtion, suggesting that context['variable name'] is not being stored. Is there a way to create a different global variable to store these values? Or any other workaround would be greatly appreciated.

3 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Sounds strange. Is the Excel sheet accessible from Maven? Maybe you need to use another path to the Excel sheet since you are running from another location?

    /Henrik
    eviware.com
  • Yes, the Excel the sheet seems to be properly working as other Test Cases pointing to the same Excel sheet run just fine and other assertions within this particular Test Case also run without error.

    It is only the case where the Test Case row needs to store a result variable for use on later rows and it is null, but it should have some value set.

    Simple Example:

    Excel sheet Var: Excel sheet assert
    foofoo1 == result1
    foofoo2 == foofoo1
    foofoo3 == foofoo1 + foofoo2


    The test request performs the following in the Script assertion:
    context['foofoo1'] = TestRequestOutput.hitCount
    JavascriptEvalAssert(context['foofoo1'] == result1)
    - Loop here -

    context['foofoo2'] = TestRequestOutput.hitCount
    JavascriptEvalAssert(context['foofoo2'] == context['foofoo1'])
    - Loop here -

    context['foofoo3'] = TestRequestOutput.hitCount
    JavascriptEvalAssert(context['foofoo3'] == context['foofoo1'] + context['foofoo2'])
    - Loop here etc.-

    As I said, the client and testRunner.sh run this fine. I only encounter the null object error when using Maven.

    The null object error being, that context['foofoo1'] is null, when in fact there should be some value.


    My initial question was, is there a way to store the variables on a different object other than 'context.
  • Found the issue:

    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> allFactories = mgr.getEngineFactories();
    for(ScriptEngineFactory engineFactory : allFactories){
    log.info("Engine Name" + engineFactory.getEngineName());
    }
    ScriptEngine engine = mgr.getEngineByName("JavaScript");
    assert engine.eval(resultJoin);

    Seems mgr.getEngineByName("JavaScript") is returning null.

    I thought this was supported after SoapUIPro v3?

    Should I use mgr.getEngineByName("groovy") instead?