【问题标题】:TestNG Emailable Report 0kbTestNG 可通过电子邮件发送的报告 0kb
【发布时间】:2025-12-06 04:45:02
【问题描述】:

我正在尝试在我的测试中使用 TestNG EmailableReporter2,但生成的 html 文件为 0kb 并且不包含任何测试。

我已经添加了

<listeners>        
    <listener class-name="org.testng.reporters.EmailableReporter2" />
</listeners>

对于我的 testng.xml,生成的报告文件没有问题,但不包含任何数据。

我有一些预感,因为在此之前对我来说效果很好。这可能是因为我的 pom.xml 有问题吗? (以前我的自动化项目中没有使用过maven)

不太可能,但这可能是因为某些代理问题吗?

我的pom.xml如下:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>package.name</groupId>
    <artifactId>ArtID</artifactId>
    <version>1.0.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>                
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.3.1</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.apache.logging.log4j</groupId>-->
            <!--<artifactId>log4j-api</artifactId>-->
            <!--<version>2.8.1</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>log4j</groupId>-->
            <!--<artifactId>log4j</artifactId>-->
            <!--<version>1.2.17</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
        </dependency>
    </dependencies>
</project>

【问题讨论】:

    标签: java automation automated-tests testng


    【解决方案1】:

    我相信您的问题已在https://github.com/cbeust/testng/issues/1412 问题中得到解答

    您尚未将 testng.xml 位置指定给 maven。

    检查: https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

    如果问题不起作用并且您认为可以,请随时重新提出问题 是一个测试问题。

    【讨论】:

    • 嗨 Krishnan,是的,我是在 github 上提出这个问题的人。但即使在编辑 pom.xml 之后,我仍然得到相同的结果。我尝试在 pom 文件中指定 testng.xml 的相对路径以及完整路径,尝试将 testng.xml 文件移动到不同的位置,但没有得到我想要的结果。你知道可能是什么问题吗?
    最近更新 更多