按不同环境执行case

一曲冷凌霜 提交于 2020-02-24 06:22:25
mvn clean test(clean表明将你上一次编译生成的一些文件删去,test表明只履行测验代码)
mvn clean test -P test(-P test 为环境参数,test为pom.xml中配置的env_config),需要在mvn命令中指定-Denv_config=test
.pom.xml里指定的profile路径需要其它变量,如:
            <resource>
                <directory>src/main/profiles/${env_config}</directory>
            </resource>
需要在mvn命令中指定-Denv_config=test


mvn clean test  -P staging 在stage环境执行
mvn clean test -P test -Dtest=MCThriftServiceTest  在test环境执行

执行指定文件
mvn clean test -P test -Dmaven.filepath=testng.xml  -DbuildUrl=$BUILD_URL -DbuildNumber=$BUILD_NUMBER -DjobName=$JOB_NAME -Ddebug=0

 

<profiles>
        <profile>
            <id>test</id>
            <properties>
                <env>test</env>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/test/resources-test</directory>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>st</id>
            <properties>
                <env>st</env>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/test/resources-st</directory>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <env>prod</env>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/test/resources-prod</directory>
                    </resource>
                </resources>
            </build>
        </profile>
    </profiles>

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!