我有套件在提供错误或异常的屏幕截图时提供直接测试。图片在目录test-output中注册。如何在报告html目录中做到这一点Reporter-output有链接吗?是否可以将它们与特定错误相关联?
答案 0 :(得分:1)
如果你的html报告在" test-output"目录和截图在"测试输出/屏幕截图"目录,然后:
(...)
String destDir = "test-output/screenshots";
String destFile = dateFormat.format(new Date()) + ".png";
FileUtils.copyFile(scrFile, new File(destDir + "/" + destFile));
Reporter.log("<a href=/screenshots/" + destFile + "><img src=/screenshots/" + destFile + " style=width:100px;height:100px;/>" + destFile + "</a><br/>");