• 搜素结果

 / 

Mock Object Testing

Google
Software Design Engineer
18026
135124
3818
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.

+加载更多

近期公开课推荐

29
六月
上海
移动应用产品设计

在移动互联网飞速发展的今天,用户体验的重…

30
六月
广东
质量保障体系设计及建设

此课程为MSUP金牌经典课程,已经在各大IT公司…

30
六月
广东
互联网高可用架构设计与实践

互联网架构师应对如今的高并发要具备哪些能…

30
六月
北京
高级性能测试与性能分析

本课程解析了性能测试理论知识,分析性能测…

30
六月
北京
领域驱动设计

领域驱动设计

课程反馈

当前课程还没有反馈信息

用户还看了其他课程

Azure实战深度解析

Azure实战深度解析

14386人看过
0人评价
高级性能测试与性能调优

高级性能测试与性能调优

7669人看过
0人评价

欢迎来到msup!

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

立即注册

服务热线

400-812-8020

market@msup.com.cn

官方微信公众号

微信公众号:msupclub

Copyright © 2017 msup

京ICP备09001521号