- Test-Driven iOS Development with Swift 4(Third Edition)
- Dr. Dominik Hauser
- 168字
- 2021-07-02 15:39:40
Green - example 1
Now, the method returns an empty string. This should be enough to make the test compile. Run the test. The test fails. But this time, it's not because the code we've written does not compile, but due to the failed assertion instead. This is not a surprise because an empty string isn't equal to "This Is A Test Headline". Following the TDD workflow, we need to go back to the implementation and add the simplest code that makes the test pass.
In ViewController, change makeHeadline(from:) to read as follows:
func makeHeadline(from string: String) -> String { return "This Is A Test Headline" }
This code is stupid and wrong, but it is the simplest code that makes the test pass. Run the tests to make sure that this is actually the case.
Even though the code we just wrote is useless for the feature we are trying to implement, it still has value for us, the developers. It tells us that we need another test.
- Java 開發(fā)從入門到精通(第2版)
- JavaScript語言精髓與編程實踐(第3版)
- Offer來了:Java面試核心知識點精講(原理篇)
- 從零開始學Linux編程
- 代替VBA!用Python輕松實現(xiàn)Excel編程
- Flask Web開發(fā):基于Python的Web應用開發(fā)實戰(zhàn)(第2版)
- ASP.NET 4.0 Web程序設計
- 循序漸進Vue.js 3前端開發(fā)實戰(zhàn)
- MATLAB計算機視覺實戰(zhàn)
- Learning Azure DocumentDB
- C++ Windows Programming
- Instant OpenCV for iOS
- 數(shù)據(jù)分析從入門到進階
- ServiceStack 4 Cookbook
- JavaScript啟示錄