S01E04: [TDD 🍅 3] Swift Closures and Recursion

preview_player
Показать описание


We begin the third tomato by sanitizing our FlowTest class. We refactor the tests by removing duplicated code, we talk about different ways for organizing the test setup code and we showcase the factory method for the creation of the system under test. These changes will prove very valuable as the project grows.

In the Flow class, we decided to solve the problem of progressing from one question to the next by using recursion.

Finally, we discussed the access control of the Flow class and we realized that only the start() method needs to be visible to the outside world, meaning the behavior of this class is being tested through this single interface!

Connect with us on:
Рекомендации по теме
Комментарии
Автор

I like how you guys go back and forth. It's helpful seeing mistakes also. Very cool

Cdswjp
Автор

adding your commits with comments would nice. Sometimes I got no idea what to write.

lukewazeak
Автор

Another question please. Interchanging the order of these lines is breaking the test. Why is that so?
   sut.start()
 router.answerCallback("A1")

gitakb
Автор

what do youu prefer should I keep coding along with you... or just watch quietly

UmairKhan-tqhq
Автор

Thanks for your video. I have a question: At 3:30. If in the i change: 
let sut = makeSUT(questions: ["Q1", "Q2"])
sut.start() 
to: 
makeSUT(questions: ["Q1", "Q2"]).start()
Why does the test break? Does Flow deinit right after makeSUT(_:) is done?

hoangsinh
Автор

This is how to eliminate your strongSelf :)

guard let `self` = self else {return}

bobgodwinx
Автор

are trying to prove that TDD is a waste of time for developing h apps? I personally think it is. Look at all that test code, and compare it to the trivial production code, which could have been written in a fraction of the time without TDD. And what happens when you login changed and you need to change the interface of the Flow? Your tests will break andreas you’ll have to rewrite them

coljackdripperofburp