Search code examples
javamavenpom.xml

Passing parameter for mvn test from pom


I have a springboot project with tests there are few parameters(for ex passwords, pins etc) i would like to pass for mvn tests, I know this can be done with -D option from the cli. Can these values be passed from pom. Below didnt seem to work, i guess this is for execution and not for compilation

<properties>
    <someproperty> abcd </someproperty>
</properties>

Solution

  • <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>@{argLine} -Dsomeproperty=someValue </argLine>
        </configuration>
    </plugin>
    

    This did the trick. Answering my question in case someone else needs this