Combine framework tutorial - Part 4 - How to include unit testing and dependency injection

preview_player
Показать описание
Let's see how we can write unit test for code that uses the Combine framework. We need to first use dependency injection to replace URLSession data task publisher with a Result publisher in the mock service.

I will write a few tests to show you different test cases and use Combine operators like collect, first, output(at). You can find the full list of Combine operators at the official Apple documentation here:
You need to scroll down a lot. Some of the operators have examples. They don't show a good use case but are a good example for implementation details.

overview:
00:00 intro
01:17 dependency injection
07:19 writing tests with Combine publishers
20:41 testing error cases
22:22 dependency injection with the Result publisher
29:05 testing if data stream completes
34:24 wrap up

The other parts of this series are:

If you liked what you learned and you want to see more, check out one of my courses!

#CombineFramework #UnitTesting
Рекомендации по теме
Комментарии
Автор

The timing of this video is pure perfection

guitaripod
Автор

Best Combine Unit Test video in YT, thank you

bozhang
Автор

I have literally no words to express how thankful I am for this tutorial. THANK YOU SOOOO MUCH!!!

singhraman
Автор

Karin, this was a super helpful tutorial and was the one that finally helped me to properly test my Combine code. Thank you so much for putting this together!

stevenr
Автор

Another great video. Loving this series. I would like to see an example of how to encode json and put or post data to a website using urlsession. Thanks

lincolndickerson
Автор

thank for the video, i got an erro with the APIMockResources and i don't understand why, " Argument type 'APIMockResources' does not conform to expected type 'DataProvider' "
because it conforme to the protocol.... please help me :(

adrienperea