【发布时间】:2018-04-06 00:02:27
【问题描述】:
我尝试运行testng.xml,结果是:
================================================
默认测试
测试运行:14,失败:6,跳过:0
默认套件
运行的测试总数:14,失败:6,跳过:0
================================================
现在,我禁用了默认的 TestNG 侦听器,并在 testng.xml 中添加了 ReportNG 侦听器。 testng.xml。看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test name="Test">
<classes>
<class name=".URL_Daily" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
按照步骤,我在maven的pom.xml中添加了velocity、guice和reportng依赖项。
在执行测试套件testng.xml 时,创建了以下文件夹(标记为红色框)。
正如预期的那样,ReportNG 应该已经创建了一个输出文件夹,这在我的场景中没有被注意到。其次,结果不同。
此外,报告index.html 看起来并不实际。谁能告诉我怎么了?
一些细节供您参考:
操作系统:Windows 7
Guice.jar 版本:guice-4.1.0
ReportNG 版本:reportng-1.1.4
Velocity 版本:velocity-dep-1.4
TestNG 版本:testng-6.11
Selenium 版本:selenium-java-3.5.3
Eclipse:eclipse oxygen
我的测试用例如下:
public class MwSites {
WebDriver driver;
@BeforeTest
public void setup ()
{
System.setProperty("webdriver.chrome.driver", "F:\\Automation\\Drivers\\Selenium Drivers\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
@AfterTest
public void Quit () throws InterruptedException
{
driver.quit();
}
@Test(priority = 0)
public void MI_Demo () throws InterruptedException
{
driver.navigate().to("http://demo.movingwalls.com/mi/#/login");
Assert.assertEquals("Login", driver.getTitle());
if (driver.getTitle()=="Login"){
System.out.println("Failed to access MI in demo environment");
}
else{
System.out.println("MI is successfully accessed in demo environment");
}
}
【问题讨论】:
-
您是否已将 testng 执行配置为以自定义方式构建报告?最好是你分享你用于上述的配置。
-
我希望你当前的workspace is same作为共享目录。你也试过refreshing the folder?
-
是的,它是同一个工作区。认真地交叉检查和重新验证每一点配置。每次执行前都会刷新文件夹。
-
在这种情况下,您能否为此共享一个可重现的代码,并使用正在使用的库版本以及您正在测试的操作系统是否相关来更新问题。
-
@nullpointer 请求完成。我已经提到了使用的库版本。
标签: java maven selenium testng reportng