官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 错那县| 昭觉县| 浦江县| 大同市| 保靖县| 泰兴市| 长沙县| 清水县| 宜兴市| 阳西县| 波密县| 民勤县| 银川市| 西吉县| 洮南市| 屏东县| 翼城县| 林甸县| 泰和县| 武宁县| 石首市| 罗田县| 利津县| 桐乡市| 梅河口市| 靖江市| 南汇区| 方山县| 西盟| 蒲城县| 图片| 台东县| 江安县| 金门县| 怀仁县| 兴义市| 南京市| 新和县| 南城县| 大方县| 左云县|