How to skip tests only for the purposes of "compilation" and "installation", but not for the "test" purpose?

I have a situation where our unit tests take a long time to complete our business domain project, because it sets the database to a known state and then performs each step. I understand that this can be done using "-Dmaven.test.skip = true" on the command line, but you want to configure this in NetBeans only for the project, it would be globally acceptable if someone could clarify how to configure in IDE

How to configure maven2 only to run tests when the target task is called?

Using the following, you disable the tests even when the target β€œtest” is called (

+6
java unit-testing maven-2 netbeans
source share
5 answers

http://maven.apache.org/general.html#skip-test

Just specify -Dmaven.test.skip = true when you call the target and do not want to run tests.

+7
source share

You can do this simply in the project properties. In NetBeans, go to "Project Properties", in the right column select "Actions". Here you can set properties for each action and each configuration (environment).

To skip tests add properties maven.test.skip = true

+4
source share

Update for NetBeans 8:

  • Right click on your project
  • Select properties
  • Go to Actions
  • Choose Maven action
  • Add Skip Tests Property

See the following image:

+3
source share

based on the project, the best way is to disable the default test execution and create a profile that enables it. Then, netbeans UI opens the project properties. The action panel and in the test, test file and test debugging actions allow the profile.

0
source share

I see that you accepted the answer to this, but let me suggest an alternative.

The type of test you are describing is an integration test ... not a unit test. True, this is still an automated test, but it depends on an external resource and can take much longer. This is an IT landmark.

Maven is built to run integration tests separately for the reasons you describe. The maven-failsafe-plugin is used to run integration tests (* IT.java instead of * Test.java), and this plugin is executed during the -test life cycle integration (while surefire intercepts the test phase).

The bottom line is that you can go all the way to the lifecycle package without performing longer tests.

Note that the installation phase comes after the integration test, and that makes sense ... if you are installing a new snapshot, you probably want to run the full test suite to make sure everything works.

0
source share

All Articles