Forum Discussion

ashkht's avatar
ashkht
Contributor
8 years ago

Failing to create directory from tear down script at Test Suite Level

Hello,

 

I am trying to generate HTML Report as part of Reporting for SOAP UI Automation. I have tried below piece of code at TestSuite Level in order to get some report. Now during this course, i am facing issue with mkdir() command which is failing to create new directory.

 

def testSuitename=runner.testSuite.getName()
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projPath2 = groovyUtils.projectPath
def timestamp = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "Timestamp" )
def tmstmpfolder1=new File(projPath2+"/SoapUIResults/"+testSuitename+timestamp).mkdir()
def failDetails1=new File(projPath2+"/SoapUIResults/"+testSuitename+"/"+"failDetails1.html")
def finalReport=new File(projPath2+"/SoapUIResults/"+testSuitename+timestamp+"/"+testSuitename+timestamp+".html")
def repHeader = new File (projPath2+"/SoapUIResults/"+testSuitename+"/"+testSuitename+" ReportHeader1.html")

 

Is it kind of caching issue, which is preventing to create new directory. Also due to which it is failing to create "ReportHeader1.html" and "testSuitename+timestamp+.html" files as highlighted in bold.

 

when i tried to troubleshoot, it results as "false" -- log.info (tmstmpfolder1)


Can you please assist me on this issue. Also please let me know if any kind of settings needs to be done at Preferences.

 

Thanks,

Ashish

  • ashkht's avatar
    ashkht
    8 years ago

    Hi Natalie,

    Thanks for your response!

     

    The SoapUIResults has been created manually and hence included as a string in file creation step. 

     

    I have troubleshooted myself and found that it was due to format of Timestamp value. I was saving Timestamp as "YYYY-mm-dd HH:mm:ss" and mkdir() command doesn't support character ":" in windows. Later i have changed format as below and was able to make directory and it worked !!

     

    Timestamp now saved as "YYYY-mm-dd HH-mm-ss". 

     

    Thank you again!

     

    Thanks,

    Ashish

  • Hi Ashish,

     

    The mkdir method fails to create a new directory if the "SoapUIResults" directory doesn't exist in your "project path" directory. Creating "SoapUIResults" manually beforehand or creating it with another mkdir call should help. Video: https://www.screencast.com/t/BgmsrENEP 

    • ashkht's avatar
      ashkht
      Contributor

      Hi Natalie,

      Thanks for your response!

       

      The SoapUIResults has been created manually and hence included as a string in file creation step. 

       

      I have troubleshooted myself and found that it was due to format of Timestamp value. I was saving Timestamp as "YYYY-mm-dd HH:mm:ss" and mkdir() command doesn't support character ":" in windows. Later i have changed format as below and was able to make directory and it worked !!

       

      Timestamp now saved as "YYYY-mm-dd HH-mm-ss". 

       

      Thank you again!

       

      Thanks,

      Ashish