[PJUG Javamail] can I do text/diff-based testing with JUnit?
Nimret Sandhu
nimret at nimret.com
Thu Oct 23 15:41:55 EDT 2008
On Thursday 23 October 2008 10:26:08 Send Here wrote:
> If that's good, you copy the output to a golden reference area, and then the
next time you run it if the current results have a diff then you know you
have something to fix:
> > I didn't expect this on the second line
>
> I suppose I could read the text as an array of Strings and write a bunch of
> JUnit assert stmts for this instead, e.g. assertEquals(lines[0], "This is
> the first line of text output"); assertEquals(lines[1], "I expect this
> result on the second line"); assertEquals(lines[2], "And this on the third
> line");
> ...but that will become very cumbersome very quickly when there is a lot of
> output, and also cumbersome when you change things intentionally and need
> to update the golden reference.
err .. unix has a 'diff' command which can be used with the '-r' flag to do a
recursive diff. you can use cygwin under windoze. check the output of the
command and it will return the diffs between the files if any were found. you
can have that emailed to someone or take appropriate action. or maybe I am
missing something .. ?
of course you could always write custom 'diff' functionality too if you want
to :)
cheers -
--
Nimret Sandhu
http://www.nimret.com
http://www.nimsoft.biz
More information about the Javamail
mailing list