首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > 一系列的“规则实现设计包装java.lang.system

一系列的“规则实现设计包装java.lang.system

  • 资源大小:8.81 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:1次
  • 资源积分:1积分
  • 标      签: java system junit rule

资 源 简 介

Occasionally applications written in a TDD environment need to interact with java.lang.System. Sometimes writing tests for this behavior gets rather involved, and is sometimes skipped. It is my hope with this library to add a few Rules (requiring Junit 4.7 or higher) to make testing these types of calls easier. For now, the following calls can be tested: * System.out * System.err * System.exit Here is a quick example of how these rules can be used: ``` public class JunitSystemRulesIntegration { @Rule public ExpectedExit expectedExit = ExpectedExit.none(); @Rule public SystemOutputRule sysout = SystemOutputRule.sysOut(); @Test public void iDoNotWantSysout() { sysout.expectToBeEmpty(); //Fails System.out.println("something"); } @Test public void iDoNotWantExit() { //Fails System.exit(1); } @Test public void exitWithDiffentStatus() { expectedExit.expectToExitWithStatus(2); //Passes System.exit(2); }

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP
0.465307s