坦白說我英文不好,
導致mock跟stub在看網路教學時都看不懂
A網站說是這樣,可是在B網站得到不一樣解釋
到底誰說的是對的
根本就不知道
於是我就去找了線上辭典對這些字的定義
然後就豁然開朗!!!!
1.mock
noun
7.
a contemptuous or derisive imitative action or speech; mockery orderision
輕蔑 嘲笑
8.
something mocked or derided; an object of derision.
9.
an imitation; counterfeit; fake.
假冒
2.stub
noun
1.
a short projecting part.
2.
a short remaining piece, as of a pencil, candle, or cigar.
3.
(in a checkbook, receipt book, etc.) the inner end of each leaf, forkeeping a record of the content of the part filled out and torn away.
4.
the returned portion of a ticket.
5.
the end of a fallen tree, shrub, or plant left fixed in the ground;stump.
6.
something having a short, blunt shape, especially a short-pointed,blunt pen.
3.fake
noun
9.
anything made to appear otherwise than it actually is; counterfeit:
This diamond necklace is a fake.
11.
a spurious report or story.
12.
Sports. a simulated play or move intended to deceive an opponent.
簡單的來說:
stub是只有一部分原功能的物件
mock就是可以跟你周旋,把你騙得團團轉的物件
fake就是你知道他現在正確的行為一定是怎樣,但是會因為時間、地點、裝置等因素不得不去做一個假的東西
後記:
對任何新觀念不要先去背(這就是這樣、那個就是那樣)
傳統教育就是這樣教的
應該要先了解為什麼會是選這個字
他所代表的概念、語意是甚麼
然後才是去了解它的用法
最後再思考
是否兩邊有吻合
如果沒有
趕快去找其他資源
一定有其中一邊錯了
不要被誤導
過了很久被人提醒才知道
原來我被網路上XXX寫的東西騙了好幾年
ref:
30天快速上手TDD Day 7 - Unit Test - Stub, Mock, Fake 簡介
Dictionary.com