您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 > Selenium
Selenium生成Report的利器-ExtentReports
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/1/20 13:48:02 ] 推薦標(biāo)簽:軟件測(cè)試工具 功能測(cè)試工具

  通常來(lái)說(shuō)如果需要看Selenium的運(yùn)行報(bào)告無(wú)非以下幾種:
  1.Eclipse+Junit 這種簡(jiǎn)單但是局限在于只能在Eclipse里看,這個(gè)是用原生的Junit單元測(cè)試框架
  2.Junit+Ant 用Ant來(lái)驅(qū)動(dòng)Selenium執(zhí)行,會(huì)生成一個(gè)xml,通過(guò)xsl樣式表來(lái)形成一個(gè)html的報(bào)告,報(bào)告比較全面,但是樣式和內(nèi)容的自定義能力比較差
  3.Testng的報(bào)告,也是Html的格式
  4.自定義的report,基本上用assert或者log來(lái)結(jié)合做一個(gè)report,直接寫html標(biāo)簽來(lái)實(shí)現(xiàn),這樣的格式自定義比較強(qiáng),但是需要編碼功底,至于樣式看個(gè)人能力了
  這里我推薦一個(gè)jar包 Extentreport  基于這個(gè)jar包來(lái)生成的html不僅美觀而且可讀取強(qiáng),如果不滿意里面的排列和內(nèi)容還可以自定義,是個(gè)生成html report的利器
  首先是下jar包,網(wǎng)上搜一下有了extentreports-java-2.40.0.jar  這里需要下連java源文件也帶上的 方便我們自定義report
  然后新建一個(gè)class文件,這里我直接貼一個(gè)例子上來(lái)

import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import com.relevantcodes.extentreports.NetworkMode;
public class ExtenseReport {
static ExtentReports extent;
static String reportLocation = "report/ExtentReport.html";
static String imageLocation = "../img/Feedback.png";
private ExtentReports createReport() {
return extent;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
extent = new ExtentReports(reportLocation, NetworkMode.OFFLINE);
String img = test.addScreenCapture(imageLocation);
test.log(LogStatus.INFO, "Image", "Image example: " + img);
extent.endTest(test);
ExtentTest test2 = extent.startTest("My First Test", "Sample description");
String aimg = test2.addScreenCapture(imageLocation);
System.out.println(img);
test2.log(LogStatus.INFO, "Image", "Image example: " + aimg);
extent.endTest(test2);
extent.flush();
}
}

  上面貼的是2個(gè)測(cè)試用例,用例里包含正確和錯(cuò)誤的測(cè)試用例以及把圖片貼進(jìn)去的例子,這個(gè)是單純的沒(méi)有用到測(cè)試框架的例子

上一頁(yè)12下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd