You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephen Connolly <st...@gmail.com> on 2008/10/06 12:24:35 UTC

Re: Surefire plugin - is there a way to activate properties/profiles based on test results?

The short answer is NO

The long answer follows:

Maven builds the project model before it starts processing the lifecycle.
Determining which profiles are active is part of building the project model.
Thus the active profiles are determined before your unit tests run.

What you are trying to do will not work the way you are trying to do it.

You either need to use multiple executions of the surefire plugin
(executions will be processed in the order in which they are defined,
and if one fails, the rest will not be executed) or attach the
surefire plugin to multiple phases (same as multiple executions, but
with more explicit ordering)

When changing from drinking the ANT coolaid to drinking the Maven
coolaid you will encounter a few bad tastes until you get used to the
flavour of the Maven coolaid. ;-)

-Stephen

2008/10/3  <MD...@up.com>:
>
>
> Hi all,
>
> I'm currently migrating an Ant script to Maven.  In Ant, we have a phased
> JUnit build set up:
>
> First, run environment checks.  If those pass, run system/integration and
> unit tests.  Otherwise, run only unit tests.
>
> We're accomplishing this using a junit task which toggles a flag on tests
> failure using "failureproperty":
> <!-- environment checks -->
>    <junit dir="${basedir}"
>           printsummary="no"
>           fork="true"
>           forkmode="once"
>           failureproperty="environmentchecks.failed"
>           errorproperty="environmentchecks.failed">
>
> Inside the second junit task, particular filesets only are tested if the
> environmentchecks.failed property is absent:
>      <batchtest todir="${junit.xml.dir}"
> unless="environmentchecks.failed">
>        <fileset refid="system.tests" />
>      </batchtest>
>
> I'd like to do the same with Maven.  I think activating a profile with
> surefire plugins specifically configured for system/integration tests will
> work, but I need a way to activate the profile, based on the Surefire
> plugin's result.  A "failureproperty" which either toggles a property, or
> activates a profile, would do the trick, but I don't see anything similar
> to this in the Surefire docs.
>
> Is there any way to accomplish this task using Surefire?
>
> Thanks,
> Matt Steele.                                                                                                                                                    This message and any attachments contain information from Union Pacific which may be confidential and/or privileged.
> If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited by law. If you receive this message in error, please contact the sender immediately and delete the message and any attachments.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org