【发布时间】:2018-07-16 08:19:07
【问题描述】:
在发布这个问题之前,我已经阅读了很多文章和 SO 帖子。我创建了 2 个 Maven 配置文件,每个环境一个。当我通过 Eclipse 的 Run As > Maven 测试运行我的 pom.xml 时,会执行测试。但是当我通过运行配置执行它时,为此目的,我创建了一个名为“测试项目”的运行配置,它的 Maven 目标设置为“测试”,配置文件设置为“暂存”,执行正在抛出
分叉进程中出现错误 [错误] com/beust/jcommander/ParameterException:不支持的 major.minor 版本 52.0 [错误] org.apache.maven.surefire.booter.SurefireBooterForkException:分叉进程中出现错误 [错误] com/beust/jcommander/ParameterException:不支持的major.minor 52.0版
如果是 java 版本问题,那么当我执行 Run As > Maven 测试时它不应该执行。
这是我的 pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>com.sample</groupId>
<artifactId>TestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>staging</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng2.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
testng.xml 和 testng2.xml 都是相似的,只是参数值不同。 这是我的 testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite verbose="0" name="Test Project suite">
<parameter name="env" value="staging" />
<test name="Test Project sample tests">
<classes>
<class name="com.sample.TestProject.AppTest" />
</classes>
</test>
</suite>
【问题讨论】:
标签: maven testng maven-profiles