JUnit 自定义规则
JUnit 4.7 引入了自定义规则的概念:
http://www.infoq .com/news/2009/07/junit-4.7-rules
有许多内置的 JUnit 规则,包括 TemporaryFolder,它有助于在运行测试后清理文件夹:
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
有内置规则的完整列表这里:
http://kentbeck.github。 com/junit/javadoc/latest/org/junit/rules/package-summary.html
我有兴趣了解您工作的地方有哪些自定义规则或者您当前使用哪些有用的自定义规则?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用@Rule进行重复测试: @Rule: 在JUnit4中利用Rule
抱歉,是中文的,但是代码和注释是英文的:)
I used @Rule for repeated test: @Rule: 在JUnit4中利用Rule
Sorry, It's Chinese, but code and comment are English:)