Question

This is how I set the values

   <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>

The test fails

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

I see

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

What am I missing here?

Was it helpful?

Solution 2

My bad, plugin was in a different module that test

OTHER TIPS

Nothing wrong!

Run it in a console mvn test

OR

Eclipse --> [project] --> Run as --> Maven test

This test maybe fail if you run it via Eclipse --> Run as --> JUnit, sometimes this action ignores the pom.xml variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top