javatar
javatar

Reputation: 4621

Is it possible to exclude or ignore junit test during a certain maven profile build?

Imagine that I have two profiles, one is for production, the other one is for test environment. The thing is, I just want to execute some tests only for development environment, not production.

I tried to put @ignore, but I cannot tell just ignore it ONLY during prod build. I tried to use sure-fire plugin of maven, but again I couldn't get it worked with different behaviour per profile.

(PS: It is a spring-hibernate project featured by such different tech.s like hazelcast, jms (activeMq), scheduler (quartz), else..)

Any help would be appreciated.

Upvotes: 2

Views: 2087

Answers (3)

javatar
javatar

Reputation: 4621

Maven's Surefire Plugin: Inclusions and Exclusions of Tests

Upvotes: 0

jddsantaella
jddsantaella

Reputation: 3687

You can ignore junit test using maven.test.skip parameter as it is described in the documentation. You can also set the parameter as part of as profile.

<profile>
  <id>noTest</id>
  ...
  <properties>
    <maven.test.skip>true</maven.test.skip>
    ...
  </properties>
  ...
</profile>

Upvotes: 2

John B
John B

Reputation: 32969

We have a system where we have three test sizes (Small, Medium and Large). We have created an annotation that allows us to mark tests with these sizes. We also created a Rule that will check a particular env variable and will skip tests based on size. Sorry, but I don't have the ability to post the code, but that is how we did it.

Here are some posts on how Google does it (we based our stuff on Google)

http://blog.utest.com/how-google-tests-software-small-medium-and-large/2011/04/

Upvotes: 2

Related Questions