Agile Java, written by Jeff Langr, walks through test-driven development with Java 5.0. It shows how to translate oral requirements into practical tests, and then shows how to use those tests. This chapter, Assertions and Annotations, shows how to build a testing tool, with full code and exercises, using Java 5's annotation facility.
Read Agile Java: Assertions and Annotations
-
Chapter from Agile Java: Assertions and Annotations (9 messages)
- Posted by: Joseph Ottinger
- Posted on: June 13 2005 09:52 EDT
Threaded Messages (9)
- Why bother with assert? by kim pepper on June 15 2005 19:11 EDT
- Why bother with assert? by Michael Lorton on June 15 2005 19:31 EDT
-
Why bother with assert? by Jeff Langr on June 16 2005 10:32 EDT
- oops by Jeff Langr on June 16 2005 10:34 EDT
-
Why bother with assert? by Jeff Langr on June 16 2005 10:32 EDT
- Why bother with assert? by Michael Lorton on June 15 2005 19:31 EDT
- Chapter from Agile Java: Assertions and Annotations by Remi Forax on June 16 2005 03:54 EDT
- Building your own testing framework by Thierry Janaudy on June 16 2005 04:46 EDT
- weird @tag uses by Daniel Haran on June 16 2005 10:54 EDT
- weird @tag uses by Mark N on June 16 2005 12:21 EDT
- weird @tag uses by Jeff Langr on June 17 2005 10:28 EDT
- weird @tag uses by Mark N on June 16 2005 12:21 EDT
-
Why bother with assert?[ Go to top ]
- Posted by: kim pepper
- Posted on: June 15 2005 19:11 EDT
- in response to Joseph Ottinger
I don't see the practicality of an assert statement if they can be switched off or, more importantly, disabled by default.
I guess this chapter is more of an academic exercise rather than providing a real testing framework alternative.
_________________
Kim Pepper -
Why bother with assert?[ Go to top ]
- Posted by: Michael Lorton
- Posted on: June 15 2005 19:31 EDT
- in response to kim pepper
I don't see the practicality of an assert statement if they can be switched off or, more importantly, disabled by default.
The whole point of an assertion is that it can be switched off. That way you can run a very expensive contract-enforcement function during dev and QA and then in production, just rely on the underlying code consistency. -
Why bother with assert?[ Go to top ]
- Posted by: Jeff Langr
- Posted on: June 16 2005 10:32 EDT
- in response to Michael Lorton
The development of the alternate test framework is somewhat of an academic exercise. However, if things are under your control--as they should be within most environments--there's no reason that depending upon annotations should be a problem. Particularly, in this case, you should be able to ensure that annotations are turned on for use in the testing framework.
-Jeff- -
oops[ Go to top ]
- Posted by: Jeff Langr
- Posted on: June 16 2005 10:34 EDT
- in response to Jeff Langr
Brain dead. Replace "annotations" with "assertions" in previous post.
-j- -
Chapter from Agile Java: Assertions and Annotations[ Go to top ]
- Posted by: Remi Forax
- Posted on: June 16 2005 03:54 EDT
- in response to Joseph Ottinger
I have notice a mistake about meta tag @Inherited (page 561),
@Inherited has no effect if used on target other than type.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/Inherited.html
Rémi -
Building your own testing framework[ Go to top ]
- Posted by: Thierry Janaudy
- Posted on: June 16 2005 04:46 EDT
- in response to Joseph Ottinger
-
weird @tag uses[ Go to top ]
- Posted by: Daniel Haran
- Posted on: June 16 2005 10:54 EDT
- in response to Joseph Ottinger
I like simplifying things. Building an Eclipse plug-in to parse @modified tags on each method doesn't seem to accomplish this. Don't we have version control to see who did what to a file?
Using @Override to make sure you don't mess up seems like a definite gain, but most of the examples in the sample chapter seem like fantasy. -
weird @tag uses[ Go to top ]
- Posted by: Mark N
- Posted on: June 16 2005 12:21 EDT
- in response to Daniel Haran
...but most of the examples in the sample chapter seem like fantasy.
Maybe. But it is the first good, real world example I've seen on how to use annotations. -
weird @tag uses[ Go to top ]
- Posted by: Jeff Langr
- Posted on: June 17 2005 10:28 EDT
- in response to Mark N
I've also used annotations to enhance JUnit 3.8.1 with the @Ignore annotation (see http://langrsoft.com/articles/annotations.shtml, written in early 2004). The goal is to raise developer awareness of temporarily-bypassed tests through the JUnit GUI. I actively use the feature, so it's definitely real world.
The @Ignore annotation will be available in the forthcoming JUnit 4. Hopefully by then Agile Java will have sold enough copies to warrant a second printing with updated JUnit information. :-)
-Jeff-