所以,我的问题一般是关于一些调试和故障排除,为那些根本不了解编程的人。是否可以创建如下方法:
public foo(method){
try(){
method();
}
catch(error){
console.log(method().name + 'caused an error');
throw Error;
}
通常可以这样做吗?是的,我知道即使没有类似的东西,错误也会显示得很好,但是如果,例如,我正在为客户做测试,他们想知道所有的事情,看看到底是什么出了问题。我想让他尽可能多地知道我的问题,我的项目已经有了诱惑记者,但这还不够。
可能是。但是有很多很好的方法可以使用logger来使用allure报告,并为您运行的每个方法提供步骤描述。
这样人们就能以人类可读的形式看到每一个被调用的动作。他们会有一个带有截图和视频的堆栈跟踪,没有比这更好的了。
在剧作家身上运用诱惑。配置文件使用
reporter: [
["allure-playwright"],
["list"]
],
列表,
"allure-commandline": "^2.13.0",
"allure-playwright": "^2.0.0-beta.14",
在package.json
你可以像这样调用每个方法
await test.step('Exatc action in method described in human readable language e.g. Click Send Button', async () => {
// ...your method
});
还有一个内置的测试错误脚本,所以您不需要自己构建。参见:
testStep.error
type: <TestError>
:https://playwright.dev/docs/api/class-teststep test-step-error
打开诱惑力:
"open-allure": "allure generate ./target/allure-results -c ./allure-report && allure open",
还有一件事剧作家有最好的调试模式在市场上,它显示你的代码和每一个操作在浏览器中见:https://playwright.dev/docs/inspector