JUnit In Action读书笔记(6)

2.5 Observing results with TestListener(Design patterns in action: Observer)
    利用此设计模式,在对象之间 ,我们可以定义一种"一对多"的依赖,那样当一个对象的state发生变化时,依赖于此的对象都得到通知并相应地自动更新.在JUnit里,把TestRunner作为一个TestListener注册到TestResult上的.(The  TestRunner registering as a  TestListener with the  TestResult is an example of the Observer pattern.)

    基于上面所说的设计模式,我们就可以很容易理解这段话了:"But does an object have to be a TestRunner to report on a test?Can more than one object report on a test at once?"JUnit框架中提供了TestListener,我们可以这个接口来access TestResult,并做出适合自己项目的测试报告.

    you would only need to implement it if you were extending the JUnit framework, rather than just using it.  

2.6 Working with TestCase

    TestRunner(shipped with the framework) +TestSuite(provided automatically by JUnit,defaultly)+ TestCase  =  TestResult
    
    这样为了得到TestResult,我们就可以只写TestCase了,通常一个TestCase包含有下面的两种主要的components: fixture和unit tests.

2.6.1 Managing resources with a fixture



   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值