剧作家测试执行报告



在测试执行之后,有没有任何方法可以在类似机器人框架的player中获得通过测试和失败测试的报告

新的内置Playwright Test Runner有许多报告程序选项。它们记录在这里:

https://playwright.dev/docs/test-reporters

目前有3种模式可以输出到终端,从非常详细的输出到非常简洁的输出。它们是列表、线条和点。

还有两种模式用于输出到文件。它们是json和junit。前者是不言自明的,后者产生JUnit风格的xml输出。

最后是生成HTML报告的选项。

可以组合这些模式来同时控制终端输出和文件输出。

您可以配置许多不同的报告程序,这实际上取决于您需要什么,"就像在机器人框架中一样";是相当广泛的,因为你也可以使用不同的记者与RF。

如果你将Playwright与摩卡一起使用,你可以配置更多的记者:

.mocharc.json:

{
"reporter-options": [
"configFile=reporter-options.json"
]
}

报告程序选项.json

{
"reporterEnabled": "mocha-simple-html-reporter, spec, mocha-junit-reporter",
"mochaSimpleHtmlReporterReporterOptions": {
"output": "./Results/report.html"
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "./Results/report-junit.xml"
}
}

显然,您必须安装依赖项:

package.json:

{
"devDependencies": {
"mocha": "~8.2.1",
"mocha-junit-reporter": "~2.0.0",
"mocha-multi-reporters": "~1.5.1",
"mocha-simple-html-reporter": "~1.1.0",
"playwright": "~1.10.0"
}
}

在此设置之后,html和junit报告将在测试运行后可用。Junit报告应该足够了,这样它就可以在管道中解析并显示在某个仪表板上。

最新更新