AutoTester999
AutoTester999

Reputation: 616

How to check build sanity using Maven for TestNG and Java?

I want to catch the compilation/code errors in my build using a maven command (in a Jenkins job).

I tried:

mvn clean install -DskipTests

This works fine but fails to catch few Java errors. For example, wrong package path in a Java class:

SampleTest.java

package apps/incorrect/path; //incorrect package path

import ....


This isn't getting caught with mvn clean install -DskipTests as it results in a successful build.

However, during the eventual run using mvn clean test, it fails as expected with the below error:

[ERROR] There was an error in the forked process
[ERROR] apps/correct/path (wrong name: oracle/incorrect/path)

Is there a different maven command to check the build sanity and also alert me to these Java code errors?

Upvotes: 0

Views: 369

Answers (1)

Rahul L
Rahul L

Reputation: 4349

Try below command

>mvn test -Dtestng.mode.dryrun=true

Upvotes: 1

Related Questions