Service Virtualization

  • 1.  Execute a testCase in another test Case through scripting

    Posted Sep 14, 2018 08:01 AM

    Is it possible to execute a test case in another test case as user controlled through scripting. Like in SOAPUI we have groovy script like testRunner.runTestStepByName($StepName) ?



  • 2.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 14, 2018 01:30 PM

    Are you specifically trying to learn how to run a test through scripting? Or are other options such as using a "Sub Process", which would allow you to run a test case within a test case?

     

    DevTest has a command line interface (CLI), TestRunner.exe, which can be used through scripting. So you can write something like this:

     

    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec("C:/DevTest/bin/TestRunner.exe -u admin -p admin -t C:/MyProject/Tests/MyTestCase.tst -m tcp://localhost:2010/Registry -a");
    int exitValue = process.waitFor();
    System.out.println("Exit Value = " + exitValue);

     

    Below are some documentation on our TestRunner CLI

    TestRunner [-h] [[-u username] [-p password] [-r StagingDocument] [-t TestCaseDocument] [-cs CoordinatorServerName]] | [-s TestSuiteDocument] [-m TestRegistryName] [-a] [-config configurationFileName] [-Dname=value]

    Test Runner - DevTest Solutions - 10.3 - CA Technologies Documentation 



  • 3.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 15, 2018 09:00 AM

    Thanks William for the reply, I have tried the same but getting below error. Seems like Scripts cannot call Runtime.exec()

     

     

    ============================================================================
    | Error in Script
    ============================================================================
    | Step: Execute Test Case
    ----------------------------------------------------------------------------
    | Message: java.lang.SecurityException: Scripts cannot call Runtime.exec()
    ----------------------------------------------------------------------------
    | Trapped Exception: java.lang.SecurityException: Scripts cannot call Runtime.exec()
    | Trapped Message: javax.script.ScriptException: java.lang.SecurityException: Scripts cannot call Runtime.exec()
    ----------------------------------------------------------------------------
    STACK TRACE
    javax.script.ScriptException: java.lang.SecurityException: Scripts cannot call Runtime.exec()
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:346)
    at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72)
    at javax.script.CompiledScript.eval(CompiledScript.java:106)
    at com.itko.lisa.test.ScriptExecHandler.executeCompiledScript(ScriptExecHandler.java:501)
    at com.itko.lisa.test.UserScriptNode._execute(UserScriptNode.java:218)
    at com.itko.lisa.editor.UserScriptNodeEditor.execute(UserScriptNodeEditor.java:214)
    at com.itko.lisa.editor.UserScriptNodeEditor.access$000(UserScriptNodeEditor.java:49)
    at com.itko.lisa.editor.UserScriptNodeEditor$1.actionPerformed(UserScriptNodeEditor.java:73)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    Caused by: java.lang.SecurityException: Scripts cannot call Runtime.exec()
    at com.itko.lisa.test.ScriptExecSecurityManager.checkExec(ScriptExecSecurityManager.java:111)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1018)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:450)
    at java.lang.Runtime.exec(Runtime.java:347)
    at java_lang_Runtime$exec$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at Script65.run(Script65.groovy:2)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:343)
    ... 43 more
    ============================================================================



  • 4.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 17, 2018 09:16 PM

    Deven,

     

    I have confirmed what you're reporting. I don't know if there's any workaround for this. Perhaps blocking Runtime.exec() is by design for security reasons.

     

    There is the option of running a testcase within a testcase through the use of a "Sub Process" step instead of scripting. Will that work?

     

    If not, can you elaborate on what the bigger picture is for what you're trying to do. That way we can think of an alternate approach for this.



  • 5.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 18, 2018 06:02 AM

    Hi Will,

     

    I am trying to build keyword driven framework (through excel) in which execution should be user controlled, in excel file I have given a column as ExecutionFlag. If value of Execution flag is Y, then it should execute a test case and if it is N then it should not execute a test case.

     

    Regards

    Deven Sharma



  • 6.  Re: Execute a testCase in another test Case through scripting

    Broadcom Employee
    Posted Sep 19, 2018 01:13 PM

    A workaround for the security constraint could be the "Execute External Command" Step.

     

    --Mike



  • 7.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 19, 2018 10:25 PM

    Hi Deven,

     

    In that case you should be able to use the Sub Process or the "Execute External Command" step as Mike pointed out, to build a test case to conditionally execute another test case based on a flag read from a data set.



  • 8.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 20, 2018 06:44 AM

    Thanks Mike and Will, I will check on the same



  • 9.  Re: Execute a testCase in another test Case through scripting

    Posted Sep 21, 2018 06:47 AM

    Hi,

     

    I am getting below error while executing in testStep "Execute External Command"

     

    Error attempting to execute the command:Runtime runtime = Runtime.getRuntime();

     

    java.io.IOException: Cannot run program "Runtime": CreateProcess error=2, The system cannot find the file specified

    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

    at java.lang.Runtime.exec(Runtime.java:620)

    at com.itko.lisa.utils.CommandLineExecNode.executeCmdLine(CommandLineExecNode.java:540)

    at com.itko.lisa.utils.CommandLineExecNode.executeCmdLine(CommandLineExecNode.java:452)

    at com.itko.lisa.utils.CommandLineExecNode.executeCmdLine(CommandLineExecNode.java:419)

    at com.itko.lisa.utils.CommandLineExecNode.executeCmdLine(CommandLineExecNode.java:405)

    at com.itko.lisa.utils.CommandLineExecEditor$4.doCallback(CommandLineExecEditor.java:411)

    at com.itko.util.swing.panels.ProcessingDialog$2.run(ProcessingDialog.java:194)

    at java.lang.Thread.run(Thread.java:745)

    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified

    at java.lang.ProcessImpl.create(Native Method)

    at java.lang.ProcessImpl.(ProcessImpl.java:386)

    at java.lang.ProcessImpl.start(ProcessImpl.java:137)

    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

    ... 8 more



  • 10.  Re: Execute a testCase in another test Case through scripting

    Broadcom Employee
    Posted Sep 21, 2018 08:41 AM

    It appears it can't find your executable.  Are you using the fully qualified path?

     

    --Mike