Migrating to Swift 4.2 using a TDD + Git workflow [S01 Extras]
Tags: swift, ios, git, tdd
Published: 2018-09-25 12:58:21

---
title: Migrating to Swift 4.2 using a TDD + Git workflow [S01 Extras]
published: true
tags: swift, ios, git, tdd
canonical_url: https://www.essentialdeveloper.com/articles/migrating-to-swift-4-2-using-a-tdd-git-workflow-s01-extras
cover_image: http://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/58921b5a6b8f5bd75e20b0f4/5baa253d15fcc0345e412117/1537878894507/thumbnail.png?format=1000w
---

{% youtube 1bYNmMILkEw %} [Watch on YouTube](https://www.youtube.com/watch?v=1bYNmMILkEw&list=PLyjgjmI1UzlSUlaQD0RvLwwW-LSlJn-F6)

In this episode, we migrate the [Quiz project](https://github.com/essentialdevelopercom/quiz-app) and its dependencies to **Swift 4.2** and modernize our code with the newest additions.

Just like in the [Swift 4](https://www.essentialdeveloper.com/articles/s01-extras-migrating-the-project-to-swift-4) and [Swift 4.1](https://www.essentialdeveloper.com/articles/migrating-to-swift-4-1-using-a-tdd-git-workflow-s01-extras) migration episodes, we migrate each module independently, while making sure that all tests are passing at every step and that we end up with no build warnings.

One delightful change that **Swift 4.2** brings is the improved ability of the compiler to synthesize an implementation of the `Hashable` protocol. We take advantage of this change and, by following our standard workflow combining `Git` and Automated Tests, we remove our custom implementation of `hashValue` we wrote for the `Question` type in [Episode 13 - Improving the Game Flow with Swift Generics](https://www.essentialdeveloper.com/articles/s01e13-improving-the-game-flow-with-swift-generics).

During the `Hashable` refactoring, we are surprised by some of the tests breaking. We resist the urge of deleting the tests by following a highly disciplined approach to solving the problem.

It’s important to notice that without **a test suite we trust**, it can be much harder to do such changes with confidence.

Finally, we take advantage of the new `Sequence.shuffled` function that **Swift 4.2** offers. We use `Sequence.shuffled` to showcase how to test randomness by using probability rather than _mocking_. By not relying on mocking, we can freely change the implementation of our code without breaking any of the tests.

[Subscribe now to our Youtube channel](https://www.youtube.com/essentialdeveloper?sub_confirmation=1) and catch **free new episodes every week**.


* * *

Originally published at [www.essentialdeveloper.com](https://www.essentialdeveloper.com/articles/number-1-reason-why-you-dont-improve-as-a-software-developer).

We’ve been helping dedicated developers to get from low paying jobs to **high tier roles – sometimes in a matter of weeks!** To do so, we continuously run and share free market researches on how to improve your skills with **Empathy, Integrity, and Economics** in mind. If you want to step up in your career, [access now our latest research for free](https://www.essentialdeveloper.com/courses/career-and-market-strategy-for-professional-ios-developers).


## Let’s connect
If you enjoyed this article, visit us at [https://essentialdeveloper.com](https://essentialdeveloper.com) and get more in-depth tailored content like this.

Follow us on: [YouTube](https://youtube.com/essentialdeveloper) • [Twitter](https://twitter.com/essentialdevcom) • [Facebook](https://facebook.com/essentialdeveloper) • [GitHub](https://github.com/essentialdevelopercom)