ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninju Bohra <ninju_bo...@yahoo.com>
Subject Re: testing ant failure
Date Fri, 11 Nov 2005 21:44:37 GMT
Have you looked at the BuildFileTest class (part of the ant-testutil.jar) that has some helpful
methods to determine whether a build file fails for the "right" reason.
 
My test methods are like:
 
    public void testMissingInputDateFailure() {
        expectSpecificBuildException("missingInputDateFailure", "missing inputDate attribute",
"Both inputDate and dateFormat need to be defined or both need to be null");
    }

Look that the code of the class for futher details but basically you pass the target name
you want call (i.e. one that you expect to fail) and it verifies that the short and long message
on the exception are what you want.
 
Hope that help avoid re-writing stuff

Thomas L Roche <tlroche@us.ibm.com> wrote:
list was more appropriate.>

How to test that an ant script fails appropriately? Specifically:

I'm working on a build app (a java app for building lots of different
things in lots of different places) that basically {creates, shleps,
invokes} ant scripts. I have a few JUnit tests on the app (and am
writing more). I'm hooking in a scanner that causes a build to fail if
a build prerequisite is not found. I know the scanner works because I
can manually

* move a prereq file so that it's not where the build expects it

* see the BUILD FAILED message corresponds to the message attribute of
the appropriate task

(Unfortunately existing, downstream tests in the current suite (that
look for the appropriate build outputs) don't fail: they greenbar (in
eclipse's runner), presumably because they don't run.)

I'd prefer to automate this, e.g. to create one or more separate
suites with

* setUp() that sets up the prereqs not-quite-correctly, then invokes
the build

* a testBuildFailed() that checks for failure

* a testBuildFailedAppropriately() that checks for appropriate failure

What's the "best way" to test for appropriate failure? The only thing
that comes to my mind is to parse the logfile, e.g.

* check for a "BUILD FAILED" line

* check that a line after the "BUILD FAILED" line contains the
appropriate failure message.

Is there an easier/better way? Note that I do have access to the app
code and scripts, and I am more-than-willing to instrument them for
testability.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org





		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message