All subjects

Framework & DevOps · Interview subject

Maven Interview Questions

Lifecycle, surefire vs failsafe, profiles and dependency scope.

51 questions

Quick interview answer

Configure maven-surefire-plugin with suiteXmlFiles and override it with -D at runtime.

Detailed explanation

Keep suite files in src/test/resources/suites and parameterise both the suite and the environment so one job serves smoke, regression and API runs.

xml
1<plugin>
2 <artifactId>maven-surefire-plugin</artifactId>
3 <version>3.2.5</version>
4 <configuration>
5 <suiteXmlFiles>
6 <suiteXmlFile>${suiteFile}</suiteXmlFile>
7 </suiteXmlFiles>
8 </configuration>
9</plugin>
10<!-- mvn clean test -DsuiteFile=suites/regression.xml -Denv=stage -->

Real-world example

One Jenkins job, three parameters, six execution combinations.

Interview tip

Know the surefire vs failsafe difference (unit vs integration tests).

Next subjectGit