Mock Object Testing

时间:该课程暂无课程排期

地点:暂无地点信息

教练:Scott McMaster

Google Software Design Engineer

Scott McMaster is a Software Design Engineer at Google in Kirkland, working on Google Code .He has taught object-oriented programming and software architecture and design as an adjunct professor in the Master of Software Engineering program at Seattle University. Prior to Google, Scott worked as a software engineer, architect, and test engineer at Microsoft, Lockheed Martin, Amazon.com, and a couple of small startups. He has a Ph.D. in Computer Science from the University of Maryland, where his thesis presented a novel approach for test coverage and test suite maintenance.

| 培训特色 |

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?

国内外知名一线技术专家分享世界级软件研发管理实践,讲述他们在知名企业的成功案例与宝贵经验。
msup与企业深度合作,并为其量身定制个性化学习课程,精心设计内容与形式,提供最高质量的学习体验。

服务热线 : 400-812-8020

邮箱: market@msup.com.cn

官网: www.msup.com.cn