Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Need a method which can trigger a specific test from the java code

oyster456 Posts: 3

I have a TestSuite which has number of Tests (lets say 20 Test),now I want to execute Test number 4 and 7 from java code using extension tool.Could let me know how do I trigger a specific test from the java code i.e. which method I have to use call to trigger that specific test?
Note:-I can't use command-line feature as it is not licensed.


  • jakubiak
    jakubiak Posts: 795 admin

    In general you cannot tell SOAtest to execute a different test from an Extension tool. However, there may be other ways to structure your tests to accomplish what you desire. Could you give us a few more details about the scenario you are trying to set up, and why you are trying to do it that way? Are there some conditions under which you want to execute tests 4 and 7? Or do you have a large number of tests in one .tst and you want to execute a couple of them from another .tst? Or something else?

  • oyster456
    oyster456 Posts: 3
    edited September 2017

    Thanks Jakublak for the reply .
    -I have a single TestSuite which has large number of test (100 test ).All these test are to be executed when the FLAG column in the
    excel spreadsheet is set to YES.
    Note:-The FLAG value can change ,depends on which test the user wants to execute.
    The excel spreadsheet is created as below:

    TestCase_ID TestCase_Name FLAG
    TC_01 Test1 YES
    TC_02 Test2 NO
    TC_03 Test3 YES
    TC_04 Test4 YES
    . . .
    . . .
    TC_99 Test99 NO
    TC_100 Test100 YES

    -Could you please help me on this,how can I implement it using extension tool or is there any other alternative?

  • oyster456
    oyster456 Posts: 3

    Hi jakubiak, Any luck on the above query

  • Thomas Moore
    Thomas Moore Posts: 82 admin
    edited September 2017

    Hi Oyster,

    The behavior you're looking for does exist, but it will take a decent amount of setup for a test of that size.

    The first thing you'll want to do is double click on your top level test suite and create two variables, in my case test and run. While both are strings, test will act like an int and run will act as a boolean.

    Next, you will want to go to the Execution Options > Test Flow Logic tab here, and for every request in your test suite, set a variable condition such that run != false.

    In my case, my true/false values are saved in a csv file, and I am only using the true/false column in it:


    Keep in mind that you will want an additional datasource in your test suite. Using only the one datasource with the excel sheet/csv/table with true/false values will run your test suite many times and throw a large number of extension tool errors when it is up, as well as possibly tests that you did not intend to run.

    If you only have the one datasource, add in a Table datasource and put in a single row, then set all of your test cases to use that new table datasource.

    Finally, create an Extension Tool. In my case, I created the script as a Groovy script, and the contents are below:

    import com.parasoft.api.*;
    public void setTestFlow(Object input, ExtensionToolContext context){
        int row = Integer.parseInt(context.getValue("test"));
        String[] runs = context.getValues("testFlow","run");
        String run = runs[row];
        context.setValue("test", (row+1).toString());
        context.setValue("run", run);

    Once the groovy script is input, ensure that all of your variables match up with how you defined them in the variables tab of your test suite, and ensure that the Extension Tool is pointing to the datasource that only has one row.

    Copy + paste the extension tool once for every test in your flow, and ensure that the tests are alternating:

    Run your test. Keep in mind that if the tst file is "open," changes to the excel file will not be read dynamically. If you "close" it by double clicking the box or right clicking your tst and selecting "Close Test (.tst) File," it will read the excel sheet contents dynamically.

    If everything is set up correctly, your test will run exactly as you have expected.

    Alternately, you could create 100 test suite variables and only use a single extension tool, but you will need to make sure in your execution options that each message client is mapped up to the appropriate variable. The Extension Tool script will also be a bit different, for example:

    import com.parasoft.api.*;
    public void setTestFlow(Object input, ExtensionToolContext context){
        int row = 0;
        String[] runs = context.getValues("testFlow","run");
        for(String run : runs)
            context.setValue("run"+row.toString(), run);

    Where each variable is named run0, run1, run2, ... , run99.

    @jakubiak, If I am missing something that makes this easier to set up, please let us know :)

  • AnushaKotra
    AnushaKotra Posts: 4

    Hi, I am trying to implememt the above scenario. Just a bit confused. Can u please let me know the below:
    1. Cvs file has only the test specific data. What will this Look like
    2. What will the table runonce look like?
    Can u please let me know how the tables will look in scenario 1 and 2?

  • AnushaKotra
    AnushaKotra Posts: 4

    Can you provide. Sample tst file or details to the above question please..