java—从系统的环境变量获取参数到测试(maven surefire)

dl5txlt9  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(300)

我在testng注解中有一个参数,我想从windows环境变量中得到运行我的测试的参数(例如测试组和url)
以下是我的pom.xml文件:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>

            <configuration>
                <groups> ${env.group}</groups>
                <systemPropertyVariables>
                    <exceutionEnviroment>${env.url}</exceutionEnviroment>

                </systemPropertyVariables>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

<properties>
    <maven.compiler.release>15</maven.compiler.release>
</properties>

测试结果如下:

@Parameters({ "url" })
@BeforeTest(alwaysRun = true)
public void startTestReport(String url){

    base = new BaseFunctions(url, Token);

}

@Parameters({ "group" })
@Test(priority = 1, groups = group, description = "Validate that patients greater than 1")

如何添加这些项目??谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题