Chapter from Agile Java: Assertions and Annotations

Discussions

News: Chapter from Agile Java: Assertions and Annotations

  1. 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

    Threaded Messages (9)

  2. Why bother with assert?[ Go to top ]

    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
  3. Why bother with assert?[ Go to top ]

    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.
  4. Why bother with assert?[ Go to top ]

    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-
  5. oops[ Go to top ]

    Brain dead. Replace "annotations" with "assertions" in previous post.

    -j-
  6. 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
  7. Hello,

    Funny enough I just put this web site yesterday testinium.org
  8. weird @tag uses[ Go to top ]

    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.
  9. weird @tag uses[ Go to top ]

    ...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.
  10. weird @tag uses[ Go to top ]

    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-