• 搜素结果

 / 

Mock Object Testing

Google
Software Design Engineer
16081
120539
1387
Mock Object Testing
推荐课程
暂无评分
推荐课程
暂无评分
¥

每人

课程时长

课程排期

如您想参加此课程,您可以点击“我想参加”按钮提交您的需求,我们会及时与您联系

地点: 该课程暂无排期
没有地点信息
将课程带入到您的团队,为您的团队进行一对一辅导。
预约内训

课程详细[html版]

课程信息

Mock objects are a powerful tool for unit testing in complex modern software systems. But mock object testing is also misunderstood by many developers who struggle to use mocks to create elegant, maintainable tests.

Based on Dr. McMaster's book, "Mock Object Testing with Examples Using EasyMock", this class will reveal how mock objects are used across the entire expect-use-verify cycle of unit testing.

培训特色

There will be a technical focus, including source code and walkthroughs based on a realistic modern web application and the popular EasyMock testing framework for Java.

课程大纲

主题 内容

Dependencies and Unit Testing

1. Testability
2. Testing modules in isolation
3. Dependency injection
4. Refactoring for dependency injection
5. Test doubles
a. Stubs
b. Mocks

Mocking Dependencies from Scratch

1. Pattern for mock object tests
a. Expect
b. Use
c. Verify
2. Building a mock without using a framework
3. Recording expectations
4. Replaying expectations
5. How to verify

Introducing Mock Object Frameworks

1. Design and implementation goals of a mock object framework
2. Our first mock object framework test case
3. Using annotations
4. Base class for mock object testing

Types of Mocks

1. Strict mocks
2. Nice mocks
3. Choosing the type of mock to use

Matching

1. What are matchers?
2. Strong and weak equality matchers
3. Boolean and comparison matchers
4. Custom matchers

Expectations

1. Expecting calls to void methods
2. Counting calls
a. Expecting a specific number of calls
b. Expecting a range of numbers
c. Expecting no calls

Mocking Results

1. Getting return values from mock methods
2. Stubbing return values
3. Calculating return values on the fly
4. Mocking exceptions

Verification

1. Verifying calls were made with:
a. Specific parameters
b. In a specific order
c. A certain number of times
2. Verifying a mock was never called
3. Automatically verifying at the end of a test case

Partial Mocks

1. Mocking classes rather than interfaces
2. Only mocking certain methods on a class with partial mocks
3. Spying
4. Limitations to partial mocking

Captures

1. Capturing parameter values in mock method calls
2. Why use captures?
a. Verifying multiple method calls
b. Especially complex input parameters

To Mock or Not?

1. Too many interfaces?
2. Dependency injection is hard?
3. Test code mirrors the implementation code?

Dependencies and Unit Testing

1. Testability
2. Testing modules in isolation
3. Dependency injection
4. Refactoring for dependency injection
5. Test doubles
a. Stubs
b. Mocks

Mocking Dependencies from Scratch

1. Pattern for mock object tests
a. Expect
b. Use
c. Verify
2. Building a mock without using a framework
3. Recording expectations
4. Replaying expectations
5. How to verify

Introducing Mock Object Frameworks

1. Design and implementation goals of a mock object framework
2. Our first mock object framework test case
3. Using annotations
4. Base class for mock object testing

Types of Mocks

1. Strict mocks
2. Nice mocks
3. Choosing the type of mock to use

Matching

1. What are matchers?
2. Strong and weak equality matchers
3. Boolean and comparison matchers
4. Custom matchers

Expectations

1. Expecting calls to void methods
2. Counting calls
a. Expecting a specific number of calls
b. Expecting a range of numbers
c. Expecting no calls

Mocking Results

1. Getting return values from mock methods
2. Stubbing return values
3. Calculating return values on the fly
4. Mocking exceptions

Verification

1. Verifying calls were made with:
a. Specific parameters
b. In a specific order
c. A certain number of times
2. Verifying a mock was never called
3. Automatically verifying at the end of a test case

Partial Mocks

1. Mocking classes rather than interfaces
2. Only mocking certain methods on a class with partial mocks
3. Spying
4. Limitations to partial mocking

Captures

1. Capturing parameter values in mock method calls
2. Why use captures?
a. Verifying multiple method calls
b. Especially complex input parameters

To Mock or Not?

1. Too many interfaces?
2. Dependency injection is hard?
3. Test code mirrors the implementation code?

+加载更多
Donec quam felis

Thousand unknown plants are noticed by me: when I hear the buzz of the little world among the stalks, and grow familiar with the countless indescribable forms of the insects and flies, then I feel the presence of the Almighty, who formed us in his own image, and the breath

I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet.

+加载更多

近期公开课推荐

31
三月
上海
卓越软件设计匠艺

1、全真案例,借助案例与设计模式知识的原理…

31
三月
广东
从零搭建用户增长体系

人人都在谈增长,究竟哪些因素影响用户增长…

31
三月
北京
项目管理最佳实践

让大家对于项目管理有个明确清晰的认识,知…

31
三月
北京
创新设计思维工作坊

你想推出新的产品与服务,却不知道该从何开…

31
三月
北京
机器学习(深度学习)算法和应用

机器学习(深度学习)算法和应用

31
三月
上海
技术管理者训练营

“猛将必发于卒伍,宰相必起于州郡”,软件…

课程反馈

当前课程还没有反馈信息

用户还看了其他课程

云计算和大数据的实践发展精要

云计算和大数据的实践发展精要

10477人看过
0人评价
SQLServer性能调优

SQLServer性能调优

42113人看过
0人评价

欢迎来到msup!

还不是msup会员?快来注册吧!

立即注册

服务热线

400-812-8020

market@msup.com.cn

官方微信公众号

微信公众号:msupclub

Copyright © 2017 msup

京ICP备09001521号