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

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.

主站蜘蛛池模板: 鄄城县| 邹平县| 望谟县| 兴业县| 松桃| 肇源县| 聂荣县| 习水县| 安康市| 道孚县| 遵义市| 二连浩特市| 恩平市| 荥阳市| 静海县| 曲阜市| 定西市| 江川县| 河西区| 东城区| 阿荣旗| 山东| 青田县| 桦南县| 南昌市| 沛县| 南华县| 德化县| 昌都县| 阿荣旗| 比如县| 定陶县| 云龙县| 莒南县| 历史| 和林格尔县| 张掖市| 韶关市| 曲阳县| 英德市| 晋宁县|