# Question about Testing Asynchronous Code

**URL:** <https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248>\
**Category:** Swift\
**Created:** [July 29, 2020, 11:22pm UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248 "2020-07-29T23:22:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/djm/32/81494_2.png) [@djm](https://forums.kodeco.com/u/djm)\
**Post date:** [July 29, 2020, 11:22pm UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248/1 "2020-07-29T23:22:43Z")

</div>

I just went through the testing tutorial found [here](https://www.raywenderlich.com/960290-ios-unit-testing-and-ui-testing-tutorial).

First off let me say that it was really useful!

I do have a question though. It seems like the Failing Fast section implies that it’s better to use the `testCallToiTunesCompletes()` test instead of the `testValidCallToiTunesGetsHTTPStatusCode200()` test. Am I understanding this correctly?

Thanks!

Dan

---

<div class="post-metadata">

**Author:** ![djm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/djm/32/81494_2.png) [@djm](https://forums.kodeco.com/u/djm)\
**Post date:** [July 30, 2020, 12:21am UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248/2 "2020-07-30T00:21:12Z")

</div>

Also, I’m getting a warning in DHURLSession when I change the deploy target to iOS 13+: “‘init()’ was deprecated in iOS 13.0”. It’s on line 49, `dataTaskMock = URLSessionDataTaskMock()`.

Any thoughts on how to deal with this?

---

<div class="post-metadata">

**Author:** ![djm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/djm/32/81494_2.png) [@djm](https://forums.kodeco.com/u/djm)\
**Post date:** [July 30, 2020, 2:53am UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248/3 "2020-07-30T02:53:42Z")

</div>

I was able to take care of the unit warning by adding `init() { }` to URLSessioDataTaskMock.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 4, 2021, 7:32am UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248/5 "2021-04-04T07:32:28Z")

</div>

@djm Really glad you sorted it out!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 4, 2021, 7:32am UTC](https://forums.kodeco.com/t/question-about-testing-asynchronous-code/116248/6 "2021-04-04T07:32:45Z")

</div>


