Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Unit Test

No description
by

Xuelan Mei

on 12 March 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Unit Test

Unit Test
and
Design

Sharon Mei
July 2013
Unit Test
Why Unit Test

What is Unit Test

How to
Design
Methodology

Principle

Patterns
Legacy
Quick hack

Cover & Modify

Refactoring
Content
Programing
Testing
Presenting
@SharonMei1219
Unit Test Basic
Why UT
Correctness
Communication
Reusebility
Good SW
Edit & Pray
or
Cover & Modify
Easy to learn/write
Quick
Targeted
UT vs. IT
What is UT
Test in very limited scope
Run Fast
Don't talk to
- data base
- network
- file system
How to
CppUTest
Practice
#include "
CppUTest/TestHarness.h
"
TEST_GROUP
(
testGroupName
){};
Unit Test Advanced
Clean UT
Dependence Breaking
As Clean as Code
Readable
name well
- given/when/then

structure well
- arrange/act/assert
To the point
One case only fail for one reason
- one assertion
- meaningful setup
- avoid branching
FIRST
Fast
Independent
Repeatable
Self-validate
Timely: don't add UT for legacy
Test for collaboration
swap
to order
just
swap

Test Double
Separation
Sensing
Difficult to construct
Hardware
Slow
Stub
Practice:
create a DDR Stub
enable it to sense the calling from cell
enable it to return color as expected
MOCK

Link seam
Dependency injection
Dependency Breaking
mock().actualCall("updateCellColor")
.withParameter("color", color);
mock().expectOneCall("updateCellColor")
.withParameter("color", RED);

mock().checkExpectations();
mock().clear();
Test
Double
Test
recording the call and parameters
check whether function called with certain parameters
TEST
(testGroupName, testName){
result = function();

CHECK_EQUAL
(expectation, result);
}
Example
Intellegent Resource Management
It's all about confidence
need a practice
in setup & teardown
Data Builder
Content for data builder
and data mother
Full transcript