ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject getting const strings into antunit tests
Date Mon, 29 Oct 2007 16:48:04 GMT

Now, one more feature for someone to add, which is a variant of what we 
added to smartfrog last week.

1. In junit tests, you can reference the Java string in the java code, 
so your tests dont break if the message changes.

2. If you test in a higher level framework (antunit, sf test compounds), 
you cant do that, so you copy and paste the string in.

3. which is very brittle.

Our solution was to add a new reference, so we can extract text from a 
java static member

testBadHost extends SSHTestExpectsFailure {
	
	action:host="missing.example.org";

	expectedText CONSTANT "org.smartfrog.services.ssh.sshExec.ERROR_NO_HOST";

}


you end up being immune to string changes, only to moved constants and 
people moving to fancy formatted strings.

seems to me, we could do the same with an ant resource, one that returns 
the toString value of a resource as its contents. then we enhance 
antunit to have a <resourceeuqals> assertion that compares two resources 
(we have something like this, right?), and we can just search for the 
specific resource in text, error logs,etc.



-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Mime
View raw message