maven surefire插件不会注入系统属性

时间:2014-05-01 17:54:57

标签: java maven maven-surefire-plugin

这是我设置值

的方法
   <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <systemProperties>
                        <property>spring.active.profiles</property>
                        <value>Test</value>
                    </systemProperties>
                    <systemPropertyVariables>
                        <spring.active.profiles>development</spring.active.profiles>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

测试失败

@Test
public void testGetProfile() throws Exception {
    assertEquals("development", System.getProperty("spring.active.profiles"));
}

我看到了

java.lang.AssertionError: 
Expected :development
Actual   :null

我在这里缺少什么?

2 个答案:

答案 0 :(得分:1)

没错!

在控制台mvn测试中运行它

OR

Eclipse - &gt; [项目] - &gt;以 - &gt;运行Maven测试

如果您通过Eclipse运行此测试可能会失败 - &gt;以 - &gt;运行JUnit,有时这个动作会忽略pom.xml变量。

答案 1 :(得分:0)

我的不好,插件是在一个不同的模块中测试

相关问题