JUnit Custom Rules

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2010-05-06T00:15:52Z Indexed on 2010/05/06 0:18 UTC
Read the original article Hit count: 316

Filed under:
|

JUnit 4.7 introduced the concept of custom rules:

http://www.infoq.com/news/2009/07/junit-4.7-rules

There are a number of built in JUnit rules including TemporaryFolder which helps by clearing up folders after a test has been run:

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();

There's a full list of built in rules here:

http://kentbeck.github.com/junit/javadoc/latest/org/junit/rules/package-summary.html

I'm interested in finding out what custom rules are in place where you work or what useful custom rules you currently use?

© Stack Overflow or respective owner

Related posts about junit

Related posts about junit4