Forum Discussion

sfosdal's avatar
sfosdal
Occasional Contributor
13 years ago

Calling and passing values to DataSink from Groovy Script

Hello,

I hope you are doing well! I am trying to run a test case that will call another test case, which will only contain a datasink test step to insert values in a oracle database.

So the test suite structure setup looks something like this:

LoggingTestCase <Test Suite>
-DBLogging <Test Case>
--Datasink <Test Step(1)>
TestingStuff1
-Test1
--DataSource
--TestRequest
--GroovyScript

Within the GroovyScript - I call the DataSink from within the DBLogging testcase.

Below code
-------------------------------------------------------------------------
def loggingTestCase = testRunner.testCase.testSuite.project.testSuites["LoggingTestCase"].testCases["DB Logging"]
def runner = loggingTestCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)

The groovy script executes accordingly and the Datasink is run however it is unable to insert data correctly because it is unable to see data from my TestingStuff test suite.

I need to preserve the DataSource and TestRequest output from the Test1 test case (within the TestingStuff1 test suite). Could you please explain how I can pass the values from the TestingStuff test suite to the LoggingTestCase test suite so the datasink will work with the values from the TestingStuff test suite?

Thanks and hopefully this explanation makes sense.

Thanks!

4 Replies

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

    could you try adding 'Run TestCase' test step to call other test case - which inserts the data ?

    Regards,
    Vladimir
    SmartBear Software
  • sfosdal's avatar
    sfosdal
    Occasional Contributor
    Hi Vladimir,

    Thanks for your quick reply! I did try your suggestion, this is almost the solution I want - my main question is: is it possible to preserve output from a test case and load that ouput into another test suite's testcase(DBLogging:datasink)? I want to be able to pass the Data Source and TestRequest output from TestingStuff1 test suite to the Logging TestCase test suite. However, when I try to use the Run TestCase test step to load my TestingStuff1 test suite data it still looking at the LoggingTestCase test suite data, I can see this by looking at the data it's inserting into the DB which does not match the TestRequest(TestingStuff1) output.
    My goal is to have this LoggingTestCase separated from other test Suites because I need multiple test suites to run the LoggingTestCase test suite and use the Datasink to insert specific logging data into Oracle. This way in the future if I ever need to change the datasink I can do it in one location as opposed to multiple testsuites that all have the datasink cloned.

    LoggingTestCase <Test Suite>
    -DBLogging <Test Case>
    --Run TestCase <Test Step(1)>
    --Datasink <Test Step(2)>
    TestingStuff1 <Test Suite>
    -Test1 <Test Case>
    --DataSource <Test Step(1)>
    --TestRequest <Test Step(2)>
    --GroovyScript <Test Step(3)>

    Thank you for your time! All help is much appreciated!
  • sfosdal's avatar
    sfosdal
    Occasional Contributor
    Hi Vladimir,

    Any more thoughts on this issue?

    Thanks for your help!
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    Try creating some TestCase Properties in TestCase B. Then create a Run TestCase TestStep in TestCase A. You will now see a table of all of TestCase B's Properties in the Run TestCase window.

    Hope this helps!

    Regards

    Henrik
    SmartBear Software