Blog Archives

How will you run test classes in Maven?

We need Surefire plugin to run the test classes in Maven. To run a single test we can call following command: mvn -Dtest=TestCaseA test We can also use patterns to run multiple test cases: mvn -Dtest=TestCase* test or mvn -Dtest=TestCaseA,TestCaseB,TestImportant*

Posted in Maven, Maven Interview Questions

Sometimes Maven compiles the test classes but doesn’t run them? What could be the reason for it?

In Maven, Surefire plugin is used for running the Tests. We can configure it to run certain test classes. Sometimes we you may have unintentionally specified an incorrect value to ${test} in settings.xml or pom.xml. We need to look for

Posted in Maven, Maven Interview Questions

How can we skip the running of tests in Maven?

We can use the parameter -Dmaven.test.skip=true or -DskipTests=true in the command line for skipping the tests. The parameter -Dmaven.test.skip=true skips the compilation of tests. The parameter -DskipTests=true skips the execution of tests Surefire plugin of Maven honors these parameters.

Posted in Maven, Maven Interview Questions

Can we create our own directory structure for a project in Maven?

Yes, Maven gives us the flexibility of creating our own directory structure. We just need to configure the elements like <sourceDirectory>, <resources> etc. in the <build> section of pom.xml.

Posted in Maven, Maven Interview Questions

What are the differences between Gradle and Maven?

Gradle is nowadays getting more popular. Google uses it for Android development and release. Companies like LinkedIn also use Gradle. Gradle is based on Domain Specific Language (DSL). Maven is based on XML. Gradle gives more flexibility to do custom

Posted in Maven, Maven Interview Questions

What is the difference between Inheritance and Multi-module in Maven?

In Maven, we can create a parent project that will pass its values to its children projects. A multi-module project is created to manage a group of other sub-projects or modules. The multi-module relationship is like a tree that starts

Posted in Maven, Maven Interview Questions

What is Build portability in Maven?

In Maven, the portability of a build is the measure of how easy it is to take a particular project and build it in different environments. A build that does not require any custom configuration or customization of properties files

Posted in Maven, Maven Interview Questions

What is the difference between a Release version and SNAPSHOT version in Maven?

A SNAPSHOT version in Maven is the one that has not been released. Before every release version there is a SNAPSHOT version. Before 1.0 release there will be 1.0-SNAPSHOT. If we download 1.0-SNAPSHOT today then we may get different set

Posted in Maven, Maven Interview Questions

How can we exclude a dependency in Maven?

To exclude a dependency we can add the tag under the section of the pom. E.g. <dependencies> <dependency> <groupId>test.ProjectX</groupId> <artifactId>ProjectX</artifactId> <version>1.0</version> <scope>compile</scope> <exclusions> <exclusion> <!– exclusion is mentioned here –> <groupId>test.ProjectY</groupId> <artifactId>ProjectY</artifactId> </exclusion> </exclusions> </dependency> </dependencies>

Posted in Maven, Maven Interview Questions

How Maven searches for JAR corresponding to a dependency?

Maven first looks for a JAR related to a dependency in the local repository. If it finds it there then it stops. If it does not find it in local repo, it looks for the JAR in the remote repository

Posted in Maven, Maven Interview Questions