Way to keep Ant "test" target from failing build if a test fails

1,231 views
Skip to first unread message

Dave

unread,
Nov 6, 2014, 12:51:18 PM11/6/14
to bndtool...@googlegroups.com
I would like the Ant build to continue and report all test failures, just like unit testing if there is a test failure. Currently a test failure will cause the build to fail and stop running (I'm using version 2.3 of Bnd):

 [bndtest] # <<<<

  [bndtest] # unset streams

  [bndtest] Tests run  : 1

  [bndtest] Passed     : 0

  [bndtest] Errors     : 1

  [bndtest] Failures   : 0

  [bndtest] # test ran

  [bndtest] # queue []

  [bndtest] 1 Error(s)

  [bndtest] Tests failed

  [bndtest] at aQute.bnd.ant.TestTask.executeProject(TestTask.java:83)

  [bndtest] at aQute.bnd.ant.TestTask.execute(TestTask.java:55)

  [bndtest] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)

  [bndtest] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)

  [bndtest] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

  [bndtest] at java.lang.reflect.Method.invoke(Method.java:606)

  [bndtest] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

  [bndtest] at org.apache.tools.ant.Task.perform(Task.java:348)

  [bndtest] at org.apache.tools.ant.Target.execute(Target.java:390)

  [bndtest] at org.apache.tools.ant.Target.performTasks(Target.java:411)

  [bndtest] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)

  [bndtest] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)

  [bndtest] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)

  [bndtest] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)

  [bndtest] at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:302)

  [bndtest] at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:221)

  [bndtest] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)

  [bndtest] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)

  [bndtest] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

  [bndtest] at java.lang.reflect.Method.invoke(Method.java:606)

  [bndtest] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

  [bndtest] at org.apache.tools.ant.Task.perform(Task.java:348)

  [bndtest] at org.apache.tools.ant.Target.execute(Target.java:390)

  [bndtest] at org.apache.tools.ant.Target.performTasks(Target.java:411)

  [bndtest] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)

  [bndtest] at org.apache.tools.ant.Project.executeTarget(Project.java:1368)

  [bndtest] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

  [bndtest] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)

  [bndtest] at org.apache.tools.ant.Main.runBuild(Main.java:809)

  [bndtest] at org.apache.tools.ant.Main.startAnt(Main.java:217)

  [bndtest] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)

  [bndtest] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)


BUILD FAILED

/Users/dhumeniuk/git/project/cnf/rootBuild.xml:94: The following error occurred while executing this line:

/Users/dhumeniuk/git/project/cnf/build-template.xml:148: Tests failed

BJ Hargrave

unread,
Nov 6, 2014, 1:30:27 PM11/6/14
to bndtool...@googlegroups.com
Did you try the ant "-keep-going” command line option?
--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 
BJ

Dave

unread,
Nov 7, 2014, 9:35:55 AM11/7/14
to bndtool...@googlegroups.com
I ended up using the failonerror property as such:

<target name="test" description="Run all integration tests">

        <!-- don't fail on error as bndtest tasks will cause build failure if a test fails --> 

        <subant target="test" failonerror="false">

            <fileset dir="${bp.workspace.dir}">

                <include name="*.integration/build.xml" />

            </fileset>

        </subant>

    </target>

I assume this does basically the same thing, but I was hoping to avoid ignoring all errors. This would mean the build will not fail if there is a real build error (e.g., if the project fails to build).

Dave

unread,
Nov 7, 2014, 9:37:55 AM11/7/14
to bndtool...@googlegroups.com
Just to clarify, "test" target is:

<target name="test" depends="compile">

        <bndtest/>

    </target>

If compile fails, I want the build as a whole to fail. If a single bnd test fails, I want to continue.

Dave

unread,
Dec 3, 2014, 1:46:44 PM12/3/14
to bndtool...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages