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

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.

主站蜘蛛池模板: 南昌市| 池州市| 阆中市| 稻城县| 大悟县| 柘城县| 富平县| 晋江市| 福泉市| 吉木萨尔县| 比如县| 盘山县| 兴文县| 瑞丽市| 绥化市| 四平市| 长顺县| 满城县| 含山县| 金门县| 万荣县| 通道| 商都县| 阿城市| 蛟河市| 富蕴县| 陆良县| 洛宁县| 石景山区| 盐池县| 肃北| 沂南县| 时尚| 葵青区| 栖霞市| 博湖县| 汝阳县| 融水| 虞城县| 洛川县| 呼和浩特市|