How to pass java code a parameter from maven for testing

This is the exact thing I was looking for my automation test and I got it working. Command Line argument mvn clean test -Denv.USER=UAT -Dgroups=Sniff My Pom Xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>TestNg</groupId> <artifactId>TestNg</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> <configuration> … Read more

The best CLI parser for Java [duplicate]

Here are some of the most popular. They are all pretty feature complete, and having used the top two I can recommend them. Commons CLI http://commons.apache.org/cli/ Java Gems http://code.google.com/p/javagems/ picocli (with colorized usage help and autocomplete) http://picocli.info/ JArgs http://jargs.sourceforge.net/ GetOpt http://www.urbanophile.com/arenn/hacking/download.html EDIT: For completeness, here are some others I’ve come across JOpt Simple http://jopt-simple.sourceforge.net/ Args4J … Read more