Intro to Unit Testing in Swift

Поділитися
Вставка
  • Опубліковано 7 жов 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.

  • @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

  • @absar66
    @absar66 Рік тому +6

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

  • @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!)

  • @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.

  • @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 😂

  • @CraigSchubert
    @CraigSchubert Рік тому +1

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

  • @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.

  • @気にしない-o8q
    @気にしない-o8q Рік тому +1

    always happy to see a new video!!!

  • @rparham1997
    @rparham1997 Рік тому +2

    Thanks! Been waiting for this one.

  • @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.

  • @davidruvinskiy6347
    @davidruvinskiy6347 Рік тому +1

    Thanks, Sean! Superb as always.

    • @seanallen
      @seanallen  Рік тому

      Glad you enjoyed it, David!

  • @yevhen_san
    @yevhen_san Рік тому +1

    Thank you for clear explanation 🙏

  • @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.

  • @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!

  • @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.

  • @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!

  • @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.

  • @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.

  • @theiosdeveloper555
    @theiosdeveloper555 Рік тому +2

    Great code!

  • @af2b
    @af2b 11 місяців тому

    thanks Sean!

  • @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.

  • @develocode7773
    @develocode7773 Рік тому +1

    Thanks!

    • @seanallen
      @seanallen  Рік тому

      I appreciate the generous support! Glad it was helpful.

  • @Neko-Pro-Watcher
    @Neko-Pro-Watcher 8 місяців тому +1

    Thanks.

  • @velcharangovindarajusreedh3048

    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!

  • @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.

  • @蔡明達-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.

  • @christophrohde1415
    @christophrohde1415 6 місяців тому

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

  • @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!

  • @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.

  • @tylerwatt5651
    @tylerwatt5651 Рік тому +1

    YESSS!!!!

  • @yevhen_san
    @yevhen_san Рік тому

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

  • @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."

  • @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!!

  • @jhoughjr1
    @jhoughjr1 Рік тому

    I really miss mocks and swift makes cheap mocks impossible.

  • @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!

  • @nroose
    @nroose 9 місяців тому

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

  • @victorriurean
    @victorriurean Рік тому +1