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

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.

主站蜘蛛池模板: 高台县| 岳西县| 南城县| 福鼎市| 韶山市| 宜春市| 五河县| 洛浦县| 武强县| 尼勒克县| 新建县| 玉龙| 大荔县| 乐山市| 垣曲县| 汽车| 米林县| 绥芬河市| 宣汉县| 日喀则市| 偃师市| 平山县| 都江堰市| 东安县| 石景山区| 荆门市| 新丰县| 漾濞| 南涧| 鄂伦春自治旗| 类乌齐县| 阜新| 河曲县| 威宁| 沽源县| 昆山市| 临邑县| 永年县| 吴旗县| 建水县| 怀化市|