如何更改testNG报告输出名称?
我的测试类是这样描述的:
private String TESTFILES = "test/tests";
@DataProvider(name = "tests")
public Iterator<Object[]> readTestFiles() {
// read a list of files ...
}
@Test(dataProvider = "tests")
public void sendRequest(File f) throws ParseException {
// do something
}
测试报告是这样的:
test\tests\text.xml
PASSED: sendRequest(test\tests\text.xml)
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
如何更改报告中的输出名称?
This one: sendRequest(test\tests\text.xml)
I'll have instead: sendRequest(text.xml)
问题是,如果数据提供者提供长文本作为刺,那么测试报告看起来很糟糕。
My test class is described like this:
private String TESTFILES = "test/tests";
@DataProvider(name = "tests")
public Iterator<Object[]> readTestFiles() {
// read a list of files ...
}
@Test(dataProvider = "tests")
public void sendRequest(File f) throws ParseException {
// do something
}
The test report is look like this:
test\tests\text.xml
PASSED: sendRequest(test\tests\text.xml)
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
How can I change the output name in the report ?
This one: sendRequest(test\tests\text.xml)
I'll have instead: sendRequest(text.xml)
The problem is, If the dataprovider is providing a long text as sting, then the test report looks horrible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试方法参数只是参数的 .toString() 扁平化。您可以将 File 参数包装在一个简单的持有者中,如下所示:
但是当然,您必须从持有者中提取文件。当我期望可能需要向 @DataProvider 输出添加更多字段并且我不想多次更改方法签名时,我发现这种技术也很有用。
The test method parameter is simply the .toString() flattening of the argument. You can wrap your File argument in a simple holder like the following:
But of course then you have to extract the file from the holder. I've found this technique useful, too, when I expect I might have to add more fields to the @DataProvider output and I don't want to have to change method signatures multiple times.