You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
“The term Inversion of Control originally meant any sort of programming style where an overall framework or runtime controlled the program flow.”—Dependency Injection: Principles, Practices, and Patterns by Mark Seemann & Steven van Deursen
“Temporal Coupling is a common problem in API design. It occurs when there’s an implicit relationship between two or more members of a class, requiring clients to invoke one member before the other. This tightly couples the members in the temporal dimension.”—Dependency Injection: Principles, Practices, and Patterns by Mark Seemann & Steven van Deursen
用自己的話講:
code 要經由特別的順序被執行, 否則會出錯, 就叫做有 temporal coupling。
我們在寫測試的時候,如果測試的每一行有執行順序的要求的話 (例如稍微換 when 區塊的兩行程式碼, 測試就會崩潰),test case 就有所謂的 temporal coupling.
因為 UIKit 的 IoC 特性 (UIKit call your code , not your code call UIKit),
所以我們的測試必須按照順序去 call sut.loadViewIfNeeded 和其他 UIKit 提供的 func (根據我們對 UIKit 的知識), 才能模擬 UIkit 的行為, 所以我們的測試就有 temporal coupling 了。
為了避免 3. 這種不好的 test case 的 smell, 老師在課堂中給了一些建議 (具體忘了...要去複習...orz.)
以上是我的理解, 大家可以補充或 debug XD.
The text was updated successfully, but these errors were encountered:
剛剛再去看了一下 IoC 和 Temporal Coupling:
Inversion of Control:
用自己的話講:
Temporal Coupling:
用自己的話講:
所以我們的測試必須按照順序去 call
sut.loadViewIfNeeded
和其他 UIKit 提供的 func (根據我們對 UIKit 的知識), 才能模擬 UIkit 的行為, 所以我們的測試就有 temporal coupling 了。以上是我的理解, 大家可以補充或 debug XD.
The text was updated successfully, but these errors were encountered: