Testng 如何为在动态生成的XmlSuite中配置的测试生成诱惑报告
我有一套测试方法(@test),我可以用Gradle任务运行,每个测试都会生成诱惑报告 但是,当我通过动态构建测试XmlSuite来运行相同的测试时,测试会按预期执行,但不会生成诱惑报告 如果我将示例方法注释为@Test,它将生成诱惑报告,但不会生成它触发的测试 有没有一种方法可以触发以这种方式执行的测试的诱惑报告Testng 如何为在动态生成的XmlSuite中配置的测试生成诱惑报告,testng,allure,Testng,Allure,我有一套测试方法(@test),我可以用Gradle任务运行,每个测试都会生成诱惑报告 但是,当我通过动态构建测试XmlSuite来运行相同的测试时,测试会按预期执行,但不会生成诱惑报告 如果我将示例方法注释为@Test,它将生成诱惑报告,但不会生成它触发的测试 有没有一种方法可以触发以这种方式执行的测试的诱惑报告 //@Test public static void guiTestInit() { // this will read a props file
//@Test
public static void guiTestInit() {
// this will read a props file after drag-and-drop and provide data for tests
Application.launch(GatherInputGui.class);
TestNG dynoTest = new TestNG();
XmlSuite suite = new XmlSuite();
suite.setName("Dyno Suite");
XmlTest test = new XmlTest(suite);
test.setName("Dyno Test");
List<XmlClass> classes = new ArrayList<XmlClass>();
XmlClass cl = new XmlClass("tests.MyTestClass");
// Add an arbitrary number of tests/methods to execure
if (getMethods().isEmpty()) {
cl.getIncludedMethods().add(new XmlInclude("defaultTestMethod", 0));
} else {
for (int i = 0; i < getMethods().size(); i++) {
cl.getIncludedMethods().add(new XmlInclude(getMethods().get(i), i));
}
}
classes.add(cl);
test.setXmlClasses(classes);
List<XmlSuite> suites = new ArrayList<XmlSuite>();
suites.add(suite);
dynoTest.setXmlSuites(suites);
//see the generated XML
//System.out.println(suite.toXml());
dynoTest.run();
}
/@测试
public static void guiTestInit(){
//这将在拖放后读取props文件,并为测试提供数据
Application.launch(GatherInputGui.class);
TestNG dynoTest=新的TestNG();
XmlSuite=newxmlsuite();
套间。套间名称(“Dyno套间”);
XmlTest=新的XmlTest(套件);
test.setName(“Dyno测试”);
列表类=新的ArrayList();
XmlClass cl=新的XmlClass(“tests.MyTestClass”);
//向Execute添加任意数量的测试/方法
if(getMethods().isEmpty()){
cl.getIncludedMethods().add(新的XmlInclude(“defaultTestMethod”,0));
}否则{
对于(int i=0;i
最终为诱惑服务器构建了一个启动器。不幸的是,我想不起我是从哪里弄来的
package gui;
导入java.io.File
公共类重新发布{
public static void launchAllure(){
try {
String currentDirectory;
File file = new File(".");
currentDirectory = file.getAbsolutePath();
System.out.println("Current working directory : "+currentDirectory);
ProcessBuilder procBuilderGenerateReports = new ProcessBuilder();
ProcessBuilder procBuilderDisplayReports = new ProcessBuilder();
/** write output and errors to log **/
File log = new File("ALLURE-LAUNCHER-LOG.log");
procBuilderGenerateReports.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
procBuilderGenerateReports.redirectError(ProcessBuilder.Redirect.appendTo(log));
procBuilderDisplayReports.redirectOutput(ProcessBuilder.Redirect.appendTo( log ));
procBuilderDisplayReports.redirectError( ProcessBuilder.Redirect.appendTo( log ));
/**
* As part of the installation of the test suite, the Allure server parts reside in a hidden directory '.allure'
* There are two files in the '.allure/allure-2.6.0/bin' directory:
* 'allure' - a UN*X shell script
* and
* 'allure.bat' - windows batch file
* They are used to start the embedded Jetty server (depending on your system) to display the test reports.
* They add allure and jetty jars to the class path and start the server, so it's impractical to try and
* start the allure server in a more granular way
*
**/
/** GENERATE THE REPORTS **/
procBuilderGenerateReports.command( currentDirectory + "\\.allure\\allure-2.6.0\\bin\\allure.bat", "generate", "--clean");
Process processGenerateReports = procBuilderGenerateReports.start();
StreamGobbler generateReportOutputGobbler = new StreamGobbler( processGenerateReports.getInputStream(), "OUTPUT" );
StreamGobbler generateReportErrorGobbler = new StreamGobbler(processGenerateReports.getErrorStream(), "ERROR");
generateReportOutputGobbler.start();
generateReportErrorGobbler.start();
/** START THE SERVER AND DISPLAY THE REPORTS **/
procBuilderDisplayReports.command( currentDirectory + "\\.allure\\allure-2.6.0\\bin\\allure.bat", "serve", currentDirectory + "\\build\\allure-results");
Process processDisplayAllureReports = procBuilderDisplayReports.start();
StreamGobbler displayReportOutputGobbler = new StreamGobbler( processDisplayAllureReports.getInputStream(), "OUTPUT" );
StreamGobbler displayReportErrorGobbler = new StreamGobbler(processDisplayAllureReports.getErrorStream(), "ERROR");
/** capture output and error to console */
displayReportOutputGobbler.start();
displayReportErrorGobbler.start();
//processDisplayAllureReports.destroy();
//processGenerateReports.destroy();
System.exit(0);
} catch (Throwable t) {
t.printStackTrace();
}
}
}面临同样的问题。你有什么解决办法吗?。。。是的,我想起来了,不幸的是,我记不起我现在做了什么,而且我现在也无法访问它。不过我会找到答案的。@Vault23,很抱歉反应太晚,我认为诱惑使用的工件是通过测试生成的,但我最终为服务器构建了一个基于JavaFX的启动器。有关更多详细信息,请参阅我的答案。但不幸的是,即使有了这个发射器,运气也不好。由于某些原因,生成的报告为空。但是当测试运行时,有很多测试/步骤等。Tbh不知道发生了什么,我应该在哪里解决它。。。我会检查这些报告的路径,我想你可以手动启动诱惑服务器来查看它们。我想再次感谢你的帮助。我解决了我的问题,它实际上与诱惑或testng无关,但您的工具非常方便和有用!