- 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.
- Mobile Application Development:JavaScript Frameworks
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Power Up Your PowToon Studio Project
- PHP基礎案例教程
- Java從入門到精通(第4版)
- Neo4j Essentials
- Building Serverless Applications with Python
- D3.js 4.x Data Visualization(Third Edition)
- Java零基礎實戰
- C++20高級編程
- Lift Application Development Cookbook
- 零基礎學HTML+CSS第2版
- Java Hibernate Cookbook
- 實戰Python網絡爬蟲
- Mastering Bootstrap 4