Groovy script to read test case name in parasoft

SrivasS5SrivasS5 Posts: 6

I am using groovy script for reading of parameter from the data source and creating of folder at the same location. I am able to do this much but now I want my folder name to be same as my test case name. Therefore can you please tell me what should be the groovy script **to read the **test case name from my test suite so that the folder could be created with the same name.


  • jakubiakjakubiak Posts: 214 ✭✭✭

    Are you doing this from an Extension Tool?

  • jakubiakjakubiak Posts: 214 ✭✭✭
    edited November 2017

    If you are doing it from an Extension Tool, you can use a script like the following:

    import com.parasoft.api.*;
    public void printName(Object input, Context context) {
        Application.showMessage("test name: " + context.getContextName());
  • SrivasS5SrivasS5 Posts: 6

    Thanks for the script.
    I used the same in my groovy script , but it is still not reading the test name from parasoft.
    Please find my groovy script and please tell me what should I add to read the test name and create folder with the same name at the location provided in my data source.

    import static java.util.Calendar.*;
    import java.text.SimpleDateFormat;
    import javax.xml.datatype.XMLGregorianCalendar;
    import java.text.DateFormat;
    import java.lang.String;
    import java.util.regex.Pattern;
    import java.sql.Timestamp;
    import com.parasoft.api.*;

    String path(input, context){
    def sdf = new java.text.SimpleDateFormat("dd-MM-yyyy hh-mm-ss aa");
    def SysDate = sdf.format( new Date()) ;
    value = context.getValue("HeaderValues", "FolderPath")
    def Name1=Application.showMessage("test name: " + context.getContextName());
    String runFolder = value+Name1+SysDate;
    def runFolderDir= new File(runFolder);

    return runFolder;


  • jakubiakjakubiak Posts: 214 ✭✭✭
    edited November 2017

    Your script is not quite correct - you are setting the value of "Name1" to the output of Application.showMessage() - which is a void function that doesn't return anything. Change that line to the following two lines:

    def Name1=context.getContextName();
    Application.showMessage("test name: " + Name1);

    context.getContextName() will give you the name of the test when running from an Extension Tool, but may not if you are running it from a script in a different tool. So if you're not using an Extension Tool, please let me know where you're inputting the script and I can help you modify it to get the test name.

Sign In or Register to comment.