Getting Started With Unit Testing | XCTest | Swift
HTML-код
- Опубликовано: 17 окт 2024
- Today, Kilo Loco covers how to get started with unit testing using XCTest in Swift.
He will cover how to refactor code out of view controllers, what code is best to start testing, and how to implement several different unit tests using functions like XCTAssertTrue and XCTAssertEqual.
Anyone looking to reduce the amount of bugs in their code and increase the amount of code coverage in their codebase should watch this tutorial.
** Show Notes and Links **
Project Files:
kilo-loco.teac...
Need Help?
kiloloco.com/m...
Kilo Loco on Social Media:
www.kiloloco.com
RUclips- / kiloloco
Twitter- / kilo_loco
Instagram- / kilo_loco
--------GEAR ------
Code Passionately T-Shirt
a.co/d/53OkIu0
Laptop - 2017 MacBook Pro
amzn.to/2tk5yLr
Keyboard - Anne Pro 2
amzn.to/2RvBcRZ
Microphone - Blue Yeti
amzn.to/34swmdC
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, we’ll receive a small commission. This helps support the channel and allows us to continue to make videos like this. Thank you for the support!
#swiftlang #xctest #unittest - Развлечения
you had me with "Real World ....", there are thousands of videos with iOS content, but it is always the same and with very basic examples, it is what the community lacked, more content creators who gave real examples , with context. And with your charisma and way of teaching it becomes very easy to understand everything. I discovered your channel recently, and you're already one of my favorite swift devs! I wish you success in everything you do !!!
Thanks Felipe, I really appreciate it!! I'm definitely going to be focusing on real world examples more often, so hopefully you continue to enjoy the content that's on its way
I think this is the most detailed and practical video on Unit Tests.. Thanks Kilo
Haha Glad you liked it!!
I love your IDE setup and theme, I remember those days a few years ago when I just was learning from you and now I work full-time. Thank you, Kyle!
Comprehensive at the same time more detailed. Thanks for making this video, this helped me a lot :-)🙂
Just when I needed this! 🙌🏽 Thanks for the great content as usual.
Thanks!! I’m glad that I could help!! 😁
Thanks for this video. Good clear way to dive into testing. 👍
I laughed so hard when you said very sexy. Made my day bro. You made horror of unit testing enjoyable.
Great tutorial Kyle! I just started learning Unit Testing. Loved the real world examples!
Hahaha Glad you liked it Mikaela. Also hmu if there are topics that you want covered. You've been following for a while now and i would like to return the favor of you supporting the channel
I was just learning this last night just to finish my project! haha good timing!
Haha crazy timing!! Hopefully this video helped
Love it!, maybe UITest and one more UnitTest but with MockUp Server, will be more realistic because every APP has a network request and its hard to Unit Test that Layer, thanks!!
Thank you so much. You made my day by explaining it this easy way.
Great introduction to XCTest! Thank you.
Thank you Kilo Loco, it is useful video. Great job!
Learnt capture error in assert throw and how to check code coverage. Thank you. 😃
My pleasure!! Hopefully I can keep providing you more value in the future
The second part of testing video would be great! With some more specific use cases and real life examples (more complex, mb?) But yep, thanks for the video, its just in time!
I'll definitely do more on testing. Looking to get into other real world examples
@@Kilo_Loco It will be nice to test network calls 👍🏾
I love how u explain everything. Tks for the tips bro
Happy to help! 😁
Learned a lot from this video. Much appreciated, Kilo.
OMG it's amazing kilo, i was deperately waiting for such type of video. Thanks man.
Haha glad that i could help
Great!. Your codes are clean and simple.Thanks for sharing your knowledge.Keep going.
Glad that you liked it 😁
Thanks! Nice video. Hopping to watch more videos regarding Unit Test 🙂
I can definitely go deeper with Unit Testing
Just earned my sub. Very nice. I look forward to watching and learning more of your material. Thank you and God bless.
Very cool video Kilo. When i heard the words "reusable code" i thought to myself "now, that's sexy". Keep up the good work and i hope you have a great experience at your new job. :D
Haha Hell YEA!!
Awesome walkthrough for starting out unit testing. You covered a lot of great stuff from start to finish in this video.
Haha glad I could help 😁
This is the best intro to unit testing video! Could you please create a video on using a page view controller, all the tutorials I have seen are really old.
This is an excellent video Kilo!
Thanks!! I'm glad that you liked it! Now make sure you start adding in tests to your project 😉
9:21 Option + shift + Enter
Mate firstly many congrats on your new job... any thoughts on Protocol oriented programming using Dependency injections ... which is in demand
Yes, I think that protocol oriented programming is a very important concept, especially for making things easier to test. I actually put together a course on POP kilo-loco.teachable.com/p/pop
Kilo Loco mate I am UK based so not sure how can I enroll for this...
great video ! very helpful!
Great video! Thanks!!
Nicely explained brother. Please explain autolayout with different scenarios.
Great video, thank you, i want UITest Cases also in next video
I will add UITests to the list of topics
Very informative 👍👍
Hi Kyle, I enrolled for the membership and waiting for the invitation to the awesome slack community. :)
Please DM your email and I'll double check
Thanks, very clear and practical.
My pleasure
In some TDD approaches "validation" will be called as "sut" - system under test. Sometimes it is convenient to see a system under test in any test file. But anyway thanks for those examples, true help for beginners in unit tests
Yea, I considered using the word sut, but I figured it would cause more confusion than simply giving it the name “validation”
Love the video and I love your IDE setup + theme. But I don't know how to configure my IDE like that
As control + shift + enter does not work on my side 😫
amazing brother! you won a subscriber
Woooow awesome man!
Do you have any plans for a UI testing video?
Amazing video! Thanks ❤️
That was great! Thank you very much!
thank you, Kilo 🤛
btw is it me or there's something wrong with the sound? it seems to be shifted a bit to the right.
Hmmm I didn’t notice it but I will definitely try to be more vigilant in the future to make sure this doesn’t pop up
I was just watching John Sundell’s lecture on unit testing, what a coincidence!
Haha, pretty crazy since we just had that podcast we recorded earlier this week
just great !
Thanks!
Nice video! Definitely helpful for beginners and a great starting point. Just a suggestion - I would make the XCTAssertTrue(username.count == 20) change to username.count >= 20 that way the test is less restrictive and does not fail for even longer usernames. Also I think testing the expectedError description is redundant. Since the above XCTAssertEqual will only pass when the error and expected error are of the same type it implies that the descriptions will be the same. I would probably just check it against a struct that keeps hold of all the app messages and test it against that. That way we test if we have the correct message for each error.
Thanks for the tips, I appreciate them 😊 Yea it definitely would have been better to do >= 20 to future proof it a little more. As for the error description, it definitely is redundant, but I thought it would be a nice way to show how to chip away at the coverage. Also, I think there are instances when things like this could actually be useful due to inconsistencies caused by conformance/inheritance
The color scheme is super juicy
any chance of you covering more in unit testing but with mocking a protocol (interface)?
Yes!! More unit testing is on its way 😉
Could you please make video on "How to write test cases for higher order functions or closures".
Hey guys. I am still in the phase of getting to know unit testing. Can anyone explain to me what was the purpose of creating methods, then checking them in a simulator, and then, after all, writing tests. Should tests not be done first? What I mean is, if we testing in a simulator first, what is the purpose of further testing in a Unit testing case? Thanks!
Another great video, we learn so much.
Just one thing I was missing - that KIlo Loco talk you do in a lot of your videos. You we're a bit too serious this one :)
Can you create more videos about Unit Testing, especially about API testing, network calls etc
Absolutely
Thank you!
Great tutorial Kyle. The best to get started on Unit Testing with practical scenario example. Request you to please make one on UI testing as well. If already made then can you please share the link of that video 👍
Brilliant! BAM..
9:19 Control+Shift+Enter does not work. Can you please tell me the name of the shortcut so that I can configure in Xcode keybinding preference?
option+Shift+Enter
I think @Hursh Hazari is correct. There are lists of shortcuts online though
Thanks @Hursh and @Kilo
How did you set xcode elements to be purple? Looks nice!
This is actually system preferences. Go to System preferences -> General -> Accent colour.
Yes, this is part of the operating system and @Nikolay Ukolov is explains it perfectly
Its Kilo Loco official color
thank you! (sorry this is the 101st comments haha)
thanks!
how to unit test without the simulator show up and running? Thanks
Hi kilo, can you make more n more videos on unit testing please
Absolutely! Which aspects of unit testing are you interested in?
thanks
Very nice!!
We don’t wanna be in the tutorial trap right? Now there is plenty to do 😁👍
Absolutely! Action is where its at
Hey can you do a video about NSOperationQueue?
Yes I most certainly can!! It’s on its way soon 😉
awesome
Thanks!
Too damn good
hi I want tutorial on generics like we have. function with parameter as sturture object and as per tht when we call function it should parse the data as per the type we want do database or some other functions as per that structure type we want
Great topic to cover. Thanks for the suggestions
suprbbbb
Thank u😁
Thank YOU for watching 😁
"No such module
CI/CD please :D
Absolutely! Some good stuff is on its way
PETER PULLER PETER PULLER.
MY SISTERS A PETER PULLER PETER PULLER.
SHE PULLS PETERS.
Great content but can’t lie…it’s a bit awkward and cringey using the term sexy during your tutorial bro 🤷🏽
I hate when you repete sexy-sexy