【问题标题】:Change .properties values from maven command line TestNG从 Maven 命令行 TestNG 更改 .properties 值
【发布时间】:2021-02-06 05:39:59
【问题描述】:

我的项目是基于 maven+TestNG+Selenium 的,我们的要求是从 maven 命令行编辑 src/test/resources/collector.properties 中存在的属性文件的值。请注意,我们有多个属性文件,只能在属性文件下方进行编辑

例如:mvn test -Dtest=ScenarioLogin#Login -Dreport.host=http://10.120.100.70:2023/api/reports/ -Dreport.token=akjfs3425645XXXX

使用上面的命令我应该能够更新以下值

collector.properties:

report.host = http://10.123.123.70:8080/api/

report.token=XXXXXXXX

POM.XML

        <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${org.apache.maven.plugins.maven-compiler-plugin.version}</version>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <source>${source.and.target.JVM.version}</source>
                            <target>${source.and.target.JVM.version}</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${org.apache.maven.plugins.maven-surefire-plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                              
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
        </build>

请帮忙看看如何实现,pom.xml中需要修改什么

【问题讨论】:

    标签: java maven testng properties-file


    【解决方案1】:

    看起来您想通过系统属性覆盖属性值。如果是这样,您的实现应该在解析属性时支持/注意。比如QAF-Testng-extension支持different ways of providing prop

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-28
      • 2013-02-16
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 2012-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多