Intro to Unit Testing in Swift

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ต.ค. 2024

ความคิดเห็น • 79

  • @seanallen
    @seanallen  ปีที่แล้ว +4

    My iOS Dev Courses (Swift, SwiftUI & UIKit) - seanallen.teachable.com

    • @KeshenMac
      @KeshenMac ปีที่แล้ว

      Hi Sean, what course is this video from? Thanks!

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      This video is stand alone. It's not from an existing course. None of my current courses go into Unit Testing. I plan on implementing testing in a future course.

    • @mario_luis_dev
      @mario_luis_dev ปีที่แล้ว +1

      hey Sean, is there overlap between the "iOS Dev Job Interview Practice" course and the "SwiftUI Mega Bundle"? I'm getting into iOS development, and I would love to take one of your courses, but I'm not sure which of these two would be a better option for me.

    • @seanallen
      @seanallen  ปีที่แล้ว +2

      No overlap. iOS Dev Job Interview Practice focuses on a take home project built in UIKit and programatic UI. The SwiftUI Mega Bundle is all my courses that focus on SwiftUI. So the answer to which way you should go depends on if you want to focus on UIKit or SwiftUI.

  • @mikewelch6970
    @mikewelch6970 ปีที่แล้ว +14

    I'm at the point where I'm learning job-ready skills. unit testing was next on my list to tackle and Then the goat pops out with a video about unit testing.

    • @seanallen
      @seanallen  ปีที่แล้ว

      Happy to help, Mike. Best of luck getting ready for the job hunt.

    • @SuaveShit
      @SuaveShit ปีที่แล้ว

      What’s your job-ready checklist?

    • @cohaya1
      @cohaya1 ปีที่แล้ว +3

      @@SuaveShitGit , thoroughly understanding json and file systems, postman , unit testing, architecture, design patterns.

  • @keef_khan
    @keef_khan ปีที่แล้ว +6

    Straightforward and easy to grasp. Thanks I've been hearing about unit testing for years but didn't actually see it in action until now.

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Happy to help.

  • @samuelp7847
    @samuelp7847 10 หลายเดือนก่อน +2

    I have a mobile app on the App Store. Unit tests didn’t make sense building the MVP. Now that it’s live, it’s so helpful knowing my tests pass before releasing an update. That’s why they make sense for me.

    • @seanallen
      @seanallen  10 หลายเดือนก่อน +1

      I agree. When you are just starting out with the MVP test aren't important. Your product is going to change too much to take the time to write tests (in my opinion). It's not worth the sacrifice in developments speed at that early stage in the products life.

  • @ammarahmad9004
    @ammarahmad9004 ปีที่แล้ว +3

    I enjoyed this topic, Its bout 9 months since I start writing tests for my code, and I think it is very important (if your code will not change in the soon future) because it makes you sure that your app has a solid foundation and you can be built more features upon it. Thanks Allen

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad you liked it :)

  • @absar66
    @absar66 ปีที่แล้ว +6

    Thank you Sean, you have a great ability of making any complex notion/concept into simple …keep going 👍

  • @TheRicherthanyouguy
    @TheRicherthanyouguy ปีที่แล้ว +3

    I've been coding a number of years and I really don't think any professional developer should deploy an app without at least about 10 % of something they have written having some form of unit testing. Even if its just we made the file did some set up and covered a single test case. Just enough to set up the foundation for adding more tests. I say this because I've found it's harder to add the very first test for code but once you get past that very first one. The rest are waaaaayyyyyy easier.

  • @abs80900
    @abs80900 ปีที่แล้ว +2

    thank you so much! I find your teaching style works for me so well, I'm so lucky and thanks a lot for your hard work and kindness to share

    • @seanallen
      @seanallen  ปีที่แล้ว

      Happy to hear you enjoyed it!

  • @neil9251
    @neil9251 ปีที่แล้ว +2

    Thanks for the nicely explained summary! Easily the most straightforward explanation and example I’ve seen. Will look to adopt this at least partially into my apps.

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad it was helpful, Neil!

  • @captainmichaelj2321
    @captainmichaelj2321 ปีที่แล้ว +2

    Thanks so much for this video! Now I really have very good visualization of unit tests and whether they are really important to me. Guess I will stick to my own simulator/device testing for the time being.

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad it was helpful!

  • @jonw4671
    @jonw4671 ปีที่แล้ว +1

    Crazy. I have just been listening to swift over coffee s1, listening to you talking about testing or lack of testing in some cases 😂

  • @aquinn4260
    @aquinn4260 ปีที่แล้ว +2

    Fantastic - Unit Tests are exactly the sort of skill that employers are looking for experience in when interviewing for Junior iOS Devs (I’m finding!)

  • @andrewboryk3904
    @andrewboryk3904 7 หลายเดือนก่อน +1

    Documentation and tests are the most neglected elements of software development, but are the most critical reasons why engineering teams begin to unravel as they scale. My suggestion, whether you are writing simple or complicated functions, over-document it with comments. What is each variable being declared, why does this conditional cause an early return, what outputs can we expect from this function.
    For tests, even when the team is small and scrappy, I recommend using them if your application has complex logic on the frontend. Granted, I always recommend putting business logic on the backend, but there is still a lot of frontend logic that determines UI state and navigation that is worth writing tests for. One example is if you have a list of lists, and there is some multi-select functionality that takes into account minimums and maximums, and auto-navigating to the next lists, write a test for it.
    General rule of thumb: documentation comment as you write, and if it is complicated for you to explain, then it deserves tests.

  • @femialiu
    @femialiu ปีที่แล้ว +3

    This is coming at the right time. Just getting into testing. Thanks a lot Sean. Will we see other testing videos?

    • @seanallen
      @seanallen  ปีที่แล้ว +2

      Possibly. But I have a very long "idea list" of videos I need to get to.

    • @femialiu
      @femialiu ปีที่แล้ว +1

      @@seanallen I understand. Thanks for all the good stuff you put out.

  • @CraigSchubert
    @CraigSchubert ปีที่แล้ว +1

    Great intro to testing - really helped me get an idea of where to start. Thanks!! 🙂

    • @seanallen
      @seanallen  ปีที่แล้ว

      happy to help, Craig.

  • @johnheaney3349
    @johnheaney3349 ปีที่แล้ว

    I've worked on embedded firmware for medical devices and unit testing is required. It's a very significant amount of work and unpleasant to boot. Other clients without FDA requirements rarely want to pay for unit testing, but our company did do some level of unit testing anyway to protect ourselves from unwanted surprises. Releasing code for manufacturing processes, for example, may not fall under FDA quidelines, but clients will still be very upset if something goes wrong.
    That said, one approach is to install unit tests in your project so that you have the infrastructure in place. Then when you do run into a bug, write unit tests to expose that bug. Then when you fix the bug you can be confident that a real world bug will not reappear some time in the future. You're probably covering some other bugs, as well. It also serves as a documented history of bug fixes.

  • @Art-is-craft
    @Art-is-craft 10 หลายเดือนก่อน

    Unit testing is not just about finding errors it can be a useful tool to help design functions and can allow you to visualise data in terms of a function.

  • @vamsi3877
    @vamsi3877 ปีที่แล้ว +1

    Nice Video Sean.Please made a video on API Testing with mock data.

    • @seanallen
      @seanallen  ปีที่แล้ว

      I'll add it to the idea list!

  • @気にしない-o8q
    @気にしない-o8q ปีที่แล้ว +1

    always happy to see a new video!!!

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Hope you enjoyed it!

  • @rparham1997
    @rparham1997 ปีที่แล้ว +2

    Thanks! Been waiting for this one.

    • @seanallen
      @seanallen  ปีที่แล้ว

      Hope you like it!

  • @alejmc
    @alejmc ปีที่แล้ว

    This is my first time looking into anything XCode tests related frameworks. I like it and a lot… I have read and/or entertained Test Driven Development (as a hobby, never in practice) and can get behind the benefits.
    There’s some functions that just get harder and tricky to test by having to launch the whole app constantly and getting to the state where the bug might or might not trigger…
    Those tests can run larger loops to test a lot of different numbers, file or directory paths (for me a pain to handle always no matter the language if it has to go through the whole UI to test), so on and so forth.
    What makes me wonder though, does XCode testing tools offer the possibility to simulate an environment?
    Let’s suppose our app needs to save to the Documents folder, so a test that finds the right folder and file name paths is understandable. And whether the app has access to the Documents folder enabled or not can be handled by an injected Boolean.
    But would it be possible to test the process of that? As in: “testSaveToFileAsksForDownloadsFolderAccess() -> void { // assert that this asks for download folder access if there’s no access available }”, or something like that where before when the test is run, macOS itself removes access to that.

  • @davidruvinskiy6347
    @davidruvinskiy6347 ปีที่แล้ว +1

    Thanks, Sean! Superb as always.

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad you enjoyed it, David!

  • @wayneosaur
    @wayneosaur 3 หลายเดือนก่อน

    Thanks for the video. The `@testable import` helps resolve compiler time errors, but I still get build errors (linker errors). There must be something I need to place in the Build Setting to make this work. Furthermore, importing the entire app seems like overkill for really large projects.

  • @yevhen_san
    @yevhen_san ปีที่แล้ว +1

    Thank you for clear explanation 🙏

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad it was helpful!

  • @mikebillysauer-nickerson6136
    @mikebillysauer-nickerson6136 10 หลายเดือนก่อน

    Actually, regression tests literally mean “going back” and testing what you did before to make sure nothing broke,it’s not that you are preventing code breakage from regressing functionality.

  • @蔡明達-k3w
    @蔡明達-k3w ปีที่แล้ว +1

    Do you have any plans to offer courses on unit testing in the future? Thank you for your video; it has been very helpful to me.

    • @seanallen
      @seanallen  ปีที่แล้ว +3

      I plan to implement unit testing into a future course. Unit testing won't be the focus of the course, but it will be added into an app we build.

  • @velcharangovindarajusreedh3048
    @velcharangovindarajusreedh3048 ปีที่แล้ว +1

    It’s really very useful video for developers, I followed all your playlists videos on time. Can you continue XCTestCases video using API calling.

    • @seanallen
      @seanallen  ปีที่แล้ว

      I'll add it to the video idea list!

  • @theiosdeveloper555
    @theiosdeveloper555 ปีที่แล้ว +2

    Great code!

  • @christophrohde1415
    @christophrohde1415 6 หลายเดือนก่อน

    What are the state-of-the-art style for benchmarks in Swift?

  • @yevhen_san
    @yevhen_san ปีที่แล้ว

    The test class will have access to the Calculation struct if it will be a separate file.

  • @af2b
    @af2b 11 หลายเดือนก่อน

    thanks Sean!

  • @AshwaniKumar-ew1cn
    @AshwaniKumar-ew1cn 2 หลายเดือนก่อน +1

    A very lovely explanation, you made things look like very easy 😅. Thanks a lot @seanallen

    • @seanallen
      @seanallen  2 หลายเดือนก่อน

      Glad it was helpful!

  • @rafael.setragni
    @rafael.setragni ปีที่แล้ว

    "Look! I designed this exotic vehicle that can reach over 100 Km/H! It's all done; it just needs to be tested. Do you want to drive it?"
    "Look! I built this building entirely from scratch, and it's all done! It just needs the calculations checked. Do you want to buy it?"
    Come on, guys! If you want to ensure that your work is correct, you need TO TEST IT, PLEASE!
    There is no such thing as "Everything is ready to go, just needs testing."

  • @develocode7773
    @develocode7773 ปีที่แล้ว +1

    Thanks!

    • @seanallen
      @seanallen  ปีที่แล้ว

      I appreciate the generous support! Glad it was helpful.

  • @Jake-Clean-Coder
    @Jake-Clean-Coder 11 หลายเดือนก่อน

    When I try to create a target for testing it says none on targets to be tested and I can't figure out why it is not allowing me to select the main Target or any for that matter. Please help!!

  • @JasonMitchellAZ
    @JasonMitchellAZ ปีที่แล้ว +1

    Unit testing is great (and important!)... We've added tests at my jobs, but now I need to figure out how to get my side app (which is using Core Data) to have some unit tests!

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Test all the things! (kidding)

    • @JasonMitchellAZ
      @JasonMitchellAZ ปีที่แล้ว +1

      @@seanallen You better get that 100% coverage in all your apps!

  • @Neko-Pro-Watcher
    @Neko-Pro-Watcher 8 หลายเดือนก่อน +1

    Thanks.

    • @seanallen
      @seanallen  7 หลายเดือนก่อน

      You're welcome

  • @jhoughjr1
    @jhoughjr1 ปีที่แล้ว

    I really miss mocks and swift makes cheap mocks impossible.

  • @AmitBiswastunebox
    @AmitBiswastunebox ปีที่แล้ว +1

    🎉 awesome Sean

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Glad you liked it!

    • @AmitBiswastunebox
      @AmitBiswastunebox ปีที่แล้ว +1

      @@seanallen I always waited for your video lol. I love your teaching style, content progression and quality of video.

  • @youngdomsey
    @youngdomsey 6 หลายเดือนก่อน

    Hello I am new to Swift. As soon as I rename my unit test from "testAdd" to just for example "add" or simply something without the "test" prefix my test disappears. Is it necessary in Swift for tests to have the "test" prefix?

    • @seanallen
      @seanallen  6 หลายเดือนก่อน +1

      Yes, the test prefix is required. That's how the system knows that piece of code is a test.

    • @youngdomsey
      @youngdomsey 6 หลายเดือนก่อน

      @@seanallen thank you!

  • @tylerwatt5651
    @tylerwatt5651 ปีที่แล้ว +1

    YESSS!!!!

    • @seanallen
      @seanallen  ปีที่แล้ว

      Hope you enjoyed it!

  • @nroose
    @nroose 9 หลายเดือนก่อน

    Why does it need a device to run a unit test? Seems so silly.

  • @victorriurean
    @victorriurean ปีที่แล้ว +1