从 Maven 设置 TestNG 的详细级别

发布于 2024-11-09 08:56:43 字数 219 浏览 0 评论 0原文

当我运行测试时,我讨厌盯着闪烁的光标而不知道正在运行什么。为了解决这个问题,我在所有测试中添加了完成消息。然而我意识到这是一个非常老套的解决方案并且增加了一些绒毛。

假设TestNG的详细级别打印测试描述,我如何在Maven中设置详细级别?请注意,我没有 test.xml 文件,因此如果这是唯一的方法,那么我不知道如何让 test.xml 文件 + Maven 自动生成的 test.xml 文件协同工作。

When I'm running tests I hate staring at a blinking cursor with no idea what's running. To fix this I've added completion messages to all my tests. However I've realized that its a really hacky solution and adds fluff.

Assuming that TestNG's verbosity level prints the test description, how can I set the verbosity level in Maven? Note that I don't have a test.xml file, so if its the only way then I have no idea how to have a test.xml file + Maven's autogenerated test.xml file work together.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

秋风の叶未落 2024-11-16 08:56:43

Surefire 允许您使用您喜欢的任何命令行参数调用 TestNG,并且 TestNG 确实支持“详细”命令行,因此可能只需执行以下操作即可

<configuration>
  <verbose>true</verbose>
</configuration>

Surefire lets you invoke TestNG with any command line parameters you like, and TestNG does support a "verbose" command line, so it's probably only a matter of doing something like

<configuration>
  <verbose>true</verbose>
</configuration>
原来分手还会想你 2024-11-16 08:56:43

maven-failsafe-plugin 版本 2.19 详细级别可以配置如下:

<configuration>
      ...
      <properties>
        <property>
          <name>surefire.testng.verbose</name>
          <value>-1</value>
        </property>
      </properties>
      ...
 </configuration>

注意:
详细级别为 0 到 10,其中 10 最详细。
-1 会将 TestNG 置于调试模式。

Since maven-failsafe-plugin version 2.19 the verbosity level can be configured as follow:

<configuration>
      ...
      <properties>
        <property>
          <name>surefire.testng.verbose</name>
          <value>-1</value>
        </property>
      </properties>
      ...
 </configuration>

Note:
The verbosity level is 0 to 10, where 10 is most detailed.
-1 will put TestNG in debug mode.

闻呓 2024-11-16 08:56:43

好吧...所以,你需要让 testng.xml 和 pom.xml 一起工作。

POM.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12.1</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>integration-test</goal>
            </goals>
            <configuration>
                <includes>
                    <include>**/*IT.java</include>
                    <include>**/*IT.groovy</include>
                </includes>
                <suiteXmlFiles>
                    <suiteXmlFile>testng-asia.xml</suiteXmlFile>
                    <suiteXmlFile>testng-emea.xml</suiteXmlFile>
                    <suiteXmlFile>testng-ny.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </execution>
        <execution>
            <id>verify</id>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

然后,在 testng*.xml 中设置详细级别,

如下所示

<suite name="TEST Ex" verbose="2" preserve-order="true" >
 <test name="NOTE"  preserve-order="true" >
    <classes>
        <class name="*IT" />
        <class name="*IT"/>
    </classes>
 </test>
</suite>

Okay... so, you need let testng.xml and pom.xml work togther.

POM.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12.1</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>integration-test</goal>
            </goals>
            <configuration>
                <includes>
                    <include>**/*IT.java</include>
                    <include>**/*IT.groovy</include>
                </includes>
                <suiteXmlFiles>
                    <suiteXmlFile>testng-asia.xml</suiteXmlFile>
                    <suiteXmlFile>testng-emea.xml</suiteXmlFile>
                    <suiteXmlFile>testng-ny.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </execution>
        <execution>
            <id>verify</id>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Then, set verbose level in testng*.xml

like that

<suite name="TEST Ex" verbose="2" preserve-order="true" >
 <test name="NOTE"  preserve-order="true" >
    <classes>
        <class name="*IT" />
        <class name="*IT"/>
    </classes>
 </test>
</suite>
凉城 2024-11-16 08:56:43

尝试 verbose level = 10。它不能解决没有 XML 的问题,但它可以为您提供更多您似乎需要的信息。

Try verbose level = 10. It doesn't solve the no XML question, but it can give you more information that you seem to need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文