Imagine, you’re running some unit-tests in your buildscript and there is a problem with one of the tests. Of course, you want to break the build. Ant has a special task for that, the fail-task that is activated due to a given property: https://ant.apache.org/manual/Tasks/fail.html
Let’s say this property is produced by your junit-task and is called „test.failure“. I don’t show the usage of junit-task here, so I use a static property in the buildscript (it’s the same):

```<project default="all" >
<property name="test.failure" value="something went really wrong." />

<target name="all">
<fail message="fail-message by christoph" if="test.failure" />
</target>

</project>
```

You simply call it and get’s the expected output:

```C:\tmp>ant
Buildfile: C:\tmp\build.xml

all:

BUILD FAILED
C:\tmp\build.xml:5: fail-message by christoph

Total time: 0 seconds
```

But what, if you want to have a special build (in my case it was sonar-build) that needs to go on, even if junit-tests fail? Here you can use the unless-param of the fail-task:

```<project default="all" >
<property name="test.failure" value="something went really wrong." />

<target name="all">
<fail message="fail-message by christoph" if="test.failure" unless="shall.never.fail" />
</target>

</project>
```

While calling the build-script with the shall.never.fail-property, the fail-task ignores the „if“-argument and goes on, even if the junit-task says, that there is a failure:

```C:\Users\cburmeis\Desktop\tmp>ant -Dshall.never.fail=true
Buildfile: C:\Users\cburmeis\Desktop\tmp\build.xml

all:

BUILD SUCCESSFUL
Total time: 0 seconds
```