2011-06-16 73 views
1

當我們執行一個測試套件或測試用例?(在測試基於WSDL)如何執行測試套件

+0

你用soapUI中? – 2011-06-16 09:24:57

+0

你試過我的下面的答案嗎?你能分享你的結果嗎?謝謝 – Suha 2012-11-07 13:42:03

+0

@Suha這裏的OP在這裏還沒有一年多的時間。 – 2012-11-07 19:47:40

回答

0

至於如何從soapUI的一個Excel工作表基於報表時,產生通過soapUI的一個Excel工作表基於報告我知道在運行測試用例或測試套件後無法創建Excel報告。一種方法可能是創建DataSink測試步驟,將數據接收器類型設置爲Excel,然後向其寫入多個屬性。

0

要將測試結果導出到Excel文件中,您需要在測試用例中創建一個常規步驟。

soapUI使用免費的Java Excel API來創建或處理Excel文件中的數據。

下面你可以找到基本的示例代碼。

import jxl.*; 
import jxl.write.*; 

// create an excel workbook 
WritableWorkbook workbook1 = Workbook.createWorkbook(new File("c:\\report.xls")); 

// create a sheet in the workbook 
WritableSheet sheet1 = workbook1.createSheet("Report Worksheet", 0); 

// Get the data to be added to the report 
def fieldFromResponse = context.expand('${Test Request#Response#declare namespace soap=\'http://www.w3.org/2003/05/soap-envelope\'; //soap:Text[1]}'); 

// create a label 
Label label = new Label(0, 0, fieldFromResponse); 

// Add the label into the sheet 
sheet1.addCell(label); 
workbook1.write(); 
workbook1.close(); 
0

下面的代碼工作創建Excel文件,使用Java Excel的API來編寫表:

import jxl.*; 
import jxl.write.*; 
import java.io.*; 

public class CreateExcel_JxlApi { 
    public static void main(String[] args) { 

     //create WorkbookSettings object 
     WorkbookSettings ws = new WorkbookSettings(); 

     try{ 
      //create work book 
      //WritableWorkbook workbook = Workbook.createWorkbook(new File("F:/Tips/JExcelTip/TestReport.xls"), ws); 
      WritableWorkbook workbook = Workbook.createWorkbook(new File("F:\\TestReport.xls"), ws); 
      System.out.println("Did excel file create?"); 

      //create work sheet 
      WritableSheet workSheet = null; 
      workSheet = workbook.createSheet("Test Report" ,0); 
      SheetSettings sh = workSheet.getSettings(); 

      //Creating Writable font to be used in the report 
      WritableFont normalFont = new WritableFont(WritableFont.createFont("MS Sans Serif"), 
      WritableFont.DEFAULT_POINT_SIZE, 
      WritableFont.NO_BOLD, false); 

      //creating plain format to write data in excel sheet 
      WritableCellFormat normalFormat = new WritableCellFormat(normalFont); 
      normalFormat.setWrap(true); 
      normalFormat.setAlignment(jxl.format.Alignment.CENTRE); 
      normalFormat.setVerticalAlignment(VerticalAlignment.CENTRE); 
      normalFormat.setWrap(true); 
      normalFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, 
      jxl.format.Colour.BLACK); 
      //write to datasheet 
      workSheet.addCell(new jxl.write.Label(0,0,"User Name",normalFormat)); 
      workSheet.addCell(new jxl.write.Label(1,0,"Password",normalFormat)); 
      //write to the excel sheet 
      workbook.write(); 
      //close the workbook 
      workbook.close(); 
    }catch(Exception e){ 
     e.printStackTrace(); 
    } 
} 
} 
0
import java.util.*; 
import java.lang.*; 
import jxl.* 
import jxl.write.* 

testCase = testRunner.testCase.testSuite.project.getTestSuiteByName('TS_CurrencyConverter').getTestCaseByName('TC_CurrencyConverter') 
def properties = new com.eviware.soapui.support.types.StringToObjectMap() 
def async = false 
def runner=testCase.run (properties, async) 

for(r in runner.results) 
{ 
    log.info(testCase.name+ ":Executed Successfully with Status " + r.status) 
    //testCase.name+ ":Executed Successfully with Status " + r.status 
    WritableWorkbook workbook1 = Workbook.createWorkbook(new File("c:/AQR/TestResult.xls")) 
    WritableSheet sheet1 = workbook1.createSheet("RunReport", 0) 
    Label TCNamelabel = new Label(0, 0, "Test Case Name"); 
    Label TCStatus= new Label(1,0,"Test Case Status"); 
    //Label TCComment= new Label(0,2,"Comment"); 
    sheet1.addCell(TCNamelabel); 
    sheet1.addCell(TCStatus); 

    Label TCANamelabel = new Label(0, 1, testCase.name); 
    Label TCAStatus= new Label(1, 1, ""+ r.status); 
    sheet1.addCell(TCANamelabel); 
    sheet1.addCell(TCAStatus); 
    workbook1.write() 
    workbook1.close() 
}