JUnit Custom Rules
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开发者_如何学Go you currently use?
I used @Rule for repeated test: @Rule: 在JUnit4中利用Rule
Sorry, It's Chinese, but code and comment are English:)
精彩评论