首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >testng.xml文件是否自动更新

testng.xml文件是否自动更新
EN

Stack Overflow用户
提问于 2014-03-19 00:17:12
回答 1查看 688关注 0票数 0

在使用mvn运行testng时,我根据需要配置了我的工作区:我的pom.xml文件配置了所有必需的依赖项,testng.xml包含所有必需的类。

然而,当我添加一个新的测试类时,testng.xml不会自动更新--它不应该从根目录开始扫描相应的测试吗?或者我必须手动更新testng.xml文件?(顺便说一句,我的工作空间是根据下面的帖子配置的:How to call testng.xml file from pom.xml in Maven)

EN

回答 1

Stack Overflow用户

发布于 2014-06-12 04:43:49

xml方法为您提供了对测试集更细粒度的控制。它不会自动改变,尽管如果您选择一个文件夹并右键单击run as testng,eclipse将动态生成xml配置。如果您只想运行所有带testng注释的测试,并且已经使用surefire或failsafe正确地配置了maven,那么您甚至不需要xml文件。只需运行"mvn verify“,所有测试都应基于注释运行。如果这不起作用,请张贴你的surefire/failsafe pom部分。

如果您想在maven中配置特定的xml,可以使用类似于(surefire或failsafe的方法同样有效):

代码语言:javascript
复制
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe.version}</version>
                <configuration>
                    <argLine>-Xmx1024m</argLine>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>testng.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

如果您确实需要更细粒度的控制,并且希望使用由maven指定的xml文件,可以通过"verify -P MyProfile“启动它。

代码语言:javascript
复制
<profiles>
        <profile>
            <id>MyProfile</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>MyProfile.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>MyOtherProfile</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>MyOtherProfile.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
<profiles>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22485065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档