java - Allure @Step 注释未出现在 Allure 报告 (Maven/TestNG) 上

标签 java maven allure

当深入研究 Allure 报告的测试时,我们看到

No information about test exection is available

未列出任何步骤。 (我们确实看到了测试,但没有看到测试步骤)

测试是通过 TestNG 使用 Maven 运行的

POM:

<properties>
        <aspectj.version>1.8.13</aspectj.version>
        <threads>1</threads>
        <groups/>
        <!-- Prevent encoding issues -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.10.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.surefire</groupId>
                <artifactId>maven-surefire-common</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>allure.results.directory</name>
                            <value>${project.build.directory}/allure-results</value>
                        </property>
                    </systemProperties>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar"
                    </argLine>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
                        </property>
                    </properties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>1.8.13</version>
                    </dependency>
                    <dependency>
                        <groupId>io.qameta.allure</groupId>
                        <artifactId>allure-testng</artifactId>
                        <version>2.12.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>

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

使用的命令: mvn 干净测试

示例测试:

    @Features("XXXX")
@Stories("XXXXX")
@Test(groups = {"xxxxxxxx"})
public class xxxxxxxxxxxx
{

    @BeforeMethod
    public void Setup() throws InterruptedException {

    }

    public void xxxxxxx() throws InterruptedException
    {
    }


    @AfterMethod
    public void shutDown()
    {

    }
}

步骤:

@Step("xxxxx")
    public XXX xxxxxx()
    {
        xxxxx.click();
        return this;
    }

不幸的是,我继承了这套测试,但不明白为什么它不起作用。已检查了该方面的设置,这是一个常见问题,看起来不错。

最佳答案

你需要设置 allure 结果目录,让 allure 知道从哪里获取这些文件。 在 <configuration> 中粘贴类似的内容部门:

<systemProperties>
   <property>
      <name>allure.results.directory</name>
      <value>${project.build.directory}/allure-results</value>
    </property>
</systemProperties>

另外,如果你想使用TestNG,你需要为TestNG导入allure。

<dependency>
 <groupId>io.qameta.allure</groupId>
 <artifactId>allure-testng</artifactId>
 <version>2.12.1</version>
</dependency>

你真的需要使用 yandex allure 插件吗?如果没有,我建议您使用 simple allure for maven 插件:

<plugin>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-maven</artifactId>
        <version>2.10.0</version>
</plugin>

关于java - Allure @Step 注释未出现在 Allure 报告 (Maven/TestNG) 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58767343/

相关文章:

java - Spring Batch 管理控制台 - com.thoughtworks.xstream.mapper.CannotResolveClassException "class : java.util.HashMap"

Maven Tomcat 插件 : can't deploy to server

java - Allure :目标文件夹中的环境文件在 maven clean 上被删除。我如何在每次构建时生成它?

java - 运行 JavaFX Maven 插件(修复类路径)后 javafx.application.Application 出现 NoClassFoundException

java - 错误 java.lang.ClassNotFoundException : com. fastxml.jackson.databind.Module

java - 是否可以在范围报告等步骤之间获得诱惑报告的屏幕截图?

倾城清洁史

java - 解释为什么这可以找到两个等于小数点后三位的数字

java - 如何否定代码生成的正则表达式中的短语?

java - 调整垃圾回收以实现低延迟