簡體   English   中英

使用groovy腳本從SoapUI中的測試用例捕獲腳本日志

[英]Capturing Script logs from a test case in SoapUI using groovy script

有人可以使用groovy腳本幫助我編寫一個腳本來從soap UI中的測試用例捕獲腳本日志。

從這里獲取: https : //community.smartbear.com/t5/SoapUI-NG/Export-http-log-to-a-file-with-groovy-script/td-p/198

快速注意,腳本日志僅記錄log.info記錄的內容。 另外,僅在您運行整個測試用例時才將日志放入腳本日志中,而不是在手動運行groovy腳本時才將日志放入。

def logArea = com.eviware.soapui.SoapUI.logMonitor
if( logArea != null )
{
   def ix = logArea.indexOfTab( "Script log" );
   if( ix >= 0 )
   {
      def logPanel = logArea.getComponentAt( ix )
      def model = logPanel.logList.model
      if( model.size > 0 )
      {
         def out = new java.io.PrintWriter( "C:/pathtofile/myfile.log" )

         for( c in 0..(model.size-1) )
            out.println( model.getElementAt( c ))

         out.close()
      }
   }
}

@canpan下面的代碼為我工作,感謝您的持續幫助

def logArea = com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log")
def LogFile = new File ("I:/SOAP UI/AutomationFramework/script.txt")
LogFile.write("Generating Script Logs...\r\n")
if (logArea != null)
{
    def model = logArea.model
    if (model.size > 0)
    {
        for (c in 0..(model.size-1))
        {
            LogFile.append(model.getElementAt(c).toString() + "\r\n")
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM