Skip to main content

Execute Cucumber from Command Line Maven

To execute Cucumber command line from terminal using Maven you need to add Maven surefire plugin in your pom.xml file. Compiler version is also recommended.

Maven surefire Plugin: The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in two different file formats Plain text files (.txt) XML files (.xml). To know the latest version and to get the more information about the Surefire plugin click here.

Maven Compiler Plugin: The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse. To read more click here.


To execute cucumber project, navigate to directory where pom.xml is located and type below command:

$ mvn test

Make sure your Runner class filename should starts or ends with Test keyword. Example filename: or

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.