Selenium Java(Maven项目):TestNG结果与ReportNG不同 [英] Selenium Java (maven project): TestNG results differs from ReportNG

查看:259
本文介绍了Selenium Java(Maven项目):TestNG结果与ReportNG不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行testng.xml,结果是:

================================================

===============================================

默认测试

运行测试:14,失败:6,跳过:0

Tests run: 14, Failures: 6, Skips: 0

默认套件

运行的总测试次数:14,失败:6,跳过次数:0

Total tests run: 14, Failures: 6, Skips: 0

================================================

===============================================

现在,我禁用了默认的TestNG侦听器,并在testng.xml中添加了ReportNG列表器. testng.xml.看起来像这样:

Now, I disabled deafult TestNG listener and added ReportNG listner in testng.xml. The testng.xml. looks like this:

<?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中添加了velocityguicereportng依赖项.

Following the steps, I added velocity, guice and reportng dependencies in maven's pom.xml.

执行测试包testng.xml后,创建了以下文件夹(用红色框标记).

Upon executing the testsuite testng.xml, following folders were created (marked in red box).

打开index.html时,结果如下:

Upon opening index.html the results are like this:

按预期,ReportNG应该已经创建了一个输出文件夹,这在我的场景中没有注意到.其次,结果是不同的.

As expected, an output folder should have been created by ReportNG which is not noticed in my scenario. Secondly, the results are different.

此外,报告index.html看起来并不实际.有人可以说出什么问题吗?

In addition, the report index.html doesn't look how actually it should be. Can somebody tell what's wrong?

一些详细信息供您参考:

Some details for your reference:

操作系统:Windows 7

OS: Windows 7

Guice.jar版本:guice-4.1.0

Guice.jar version: guice-4.1.0

ReportNG版本:reportng-1.1.4

ReportNG Version: reportng-1.1.4

速度版本:velocity-dep-1.4

TestNG版本:testng-6.11

TestNG Version: testng-6.11

硒版本: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");
    }
}

推荐答案

由于跳过了测试,您可能需要首先检查xml的测试结果以找出根本原因(例外).

As your tests got skipped, you may want to check test results xml first to find out the root cause (exception).

另一方面,我只是想知道使用未维护4年的库的最初意图是什么? ReportNG已死.这是事实.并且,如果您查看它的源代码,就会看到它使用哪个TestNG版本(6.8).您可以轻松地假设其报告器基于旧的TestNG API.

On the other hand, I'm just wondering what's the initial intention of using a library, which is not maintained for 4 years? ReportNG is dead. It's a fact. And if you take a look at its sources, you'll see which TestNG version it uses (6.8). You could easily assume that its reporter is based on old TestNG API.

当添加TestNG 6.11作为依赖项时,发生地狱的可能性很高.如果这是您问题的根本原因,我也不会感到惊讶.

When you add TestNG 6.11 as a dependency, the probability of a jar hell occurrence is quite high. And I wouldn't be surprised, if it's a root cause of your issue.

如果您尚未决定要使用哪种报告系统,我建议您看一下现代的

If you haven't decided which reporting system to use yet, I'd recommend to take a look at a modern Allure 2 framework.

否则,只需首先检查堆栈跟踪以了解问题的根本原因.

Otherwise, just check a stacktrace first to understand the root cause of your issue.

这篇关于Selenium Java(Maven项目):TestNG结果与ReportNG不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆