Intro to Unit Testing in C# using XUnit

Sdílet
Vložit
  • čas přidán 19. 06. 2024
  • Unit testing is an important part of writing quality software. It is also a controversial and somewhat difficult topic to get started in. In this video, we walk through why we would use unit testing, what a unit test is, how to create a test, and how to deal with some of the more difficult situations.
    Along the way, we will cover best practices, the pitfalls to avoid, and how to write more testable code.
    This video uses XUnit instead of NUnit or MSTest based upon my preference. However, the techniques taught will apply to other test types.
    Newsletter signup (with exclusive discounts): signup.iamtimcorey.com/ (your email will be kept safe and you will not be spammed).
    Source Code (and homework): leadmagnets.app/?Resource=Int...
    0:00 - Intro
    1:37 - Working environment
    3:35 - Demo application walk-through
    7:14 - Unit Testing explained
    9:45 - Creating a Unit Test project
    13:22 - Setting up a test
    22:37 - A bad Unit Test and Test Driven Development
    25:48 - Opinion on Unit Testing
    28:40 - Shortening Test name
    31:08 - "Theory": Test method parameters and arguments
    36:09 - Testing edge cases
    38:43 - Testing number division
    43:13 - Dividing by zero
    48:55 - Testing methods that can throw exceptions: method returns output
    54:14 - Debugging the Unit Test
    55:19 - Testing the exceptions: method throws exception
    59:22 - Testing the exceptions: method argument throws exception
    1:05:07 - Testing methods that do more than one thing: what is a Unit of work?
    1:10:56 - Breaking method in to individual methods, what to test and what not to test
    1:18:50 - "Add to List" Tests: working test
    1:26:50 - "Add to List" Tests: failing test
    1:35:37 - Homework
    1:40:05 - Concluding remarks

Komentáře • 549

  • @JackiePrime
    @JackiePrime Před 6 lety +310

    I like that you don't edit out the times where things don't work as expected. It's actually helpful.

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +128

      Excellent. Part of it is just wanting everyone to relax and not think you have to be perfect (I'm sure not). Part of it is that I do think it shows a realistic view on what I do as a developer. I am glad it is helpful to you.

    • @abidmabdelaziz
      @abidmabdelaziz Před 4 lety +7

      I never used my eraser in math or physics exercises for this very reason :).

    • @GonzaloRMDT
      @GonzaloRMDT Před 4 lety +4

      Totally agree. Thanks for making mistakes LOL

    • @AnalogGame
      @AnalogGame Před 3 lety +2

      Completely agree! seeing what did not work is useful, so whoever is watching this video can learn from it

  • @RalfsBalodis
    @RalfsBalodis Před 3 lety +61

    0:00 - Intro
    1:37 - Working environment
    3:35 - Demo application walk-through
    7:14 - Unit Testing explained
    9:45 - Creating a Unit Test project
    13:22 - Setting up a test
    22:37 - A bad Unit Test and Test Driven Development
    25:48 - Opinion on Unit Testing
    28:40 - Shortening Test name
    31:08 - "Theory": Test method parameters and arguments
    36:09 - Testing edge cases
    38:43 - Testing number division
    43:13 - Dividing by zero
    48:55 - Testing methods that can throw exceptions: method returns output
    54:14 - Debugging the Unit Test
    55:19 - Testing the exceptions: method throws exception
    59:22 - Testing the exceptions: method argument throws exception
    1:05:07 - Testing methods that do more than one thing: what is a Unit of work?
    1:10:56 - Breaking method in to individual methods, what to test and what not to test
    1:18:50 - "Add to List" Tests: working test
    1:26:50 - "Add to List" Tests: failing test
    1:35:37 - Homework
    1:40:05 - Concluding remarks

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety +11

      Greatly appreciated by myself and the other students.

  • @kchilka
    @kchilka Před 4 lety +18

    "the way you get good at something is to not watch videos, but by doing it!" - so true!

  • @rumenstoyanov1701
    @rumenstoyanov1701 Před 4 lety +14

    This was a truly great video. Not only was the educational content about the specific subject matter of unit testing fantastic, but also, just taking the time to carefully convey the fundamentals serves to remind us all that development and engineering is not about just quickly getting through things, but that it is about long term excellence and profound understanding.

  • @chrismantonuk
    @chrismantonuk Před 4 lety +6

    Hi Tim. Thanks for the great tutorial (and the follow up Moq video). I've always grumbled about testing, but this has opened my eyes to see that it can really be super satisfying and fun. I've had lots of fun today extending your sample project with tests for the CSV serialize/deserialize and theories around handling bad input etc. All round top notch stuff, thanks mate!

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety

      Thank you!

    • @jimmcneal
      @jimmcneal Před 3 lety

      @@IAmTimCorey Also, I agree 100% w/ your philosophy on the testing fanatics. They have definitely deterred me from getting into Unit Testing in the past. Thanks for the help.

  • @user-wj5qd5fy1n
    @user-wj5qd5fy1n Před 2 lety

    The best explanation and the most detailed for free accessible video about this topic. You are really the man!

  • @raduen2
    @raduen2 Před 4 lety +14

    This is how you make a tutorial! All of them all greate. I was like test code cost me more time but now I see the benefits and expecialy how you show it in this tutorial

  • @liwang9544
    @liwang9544 Před 3 lety

    Always clear and organized. Appreciate your tutorials. Even your voice is soothing. THANK YOU!

  • @rodcka
    @rodcka Před 3 lety

    Great video, as always. I've worked with xUnit before but now I've learned a lot of xUnit, unit tests and best practices. Thank you for sharing your knowledge. I'm definitively going to practice it right away. =)

  • @claybizjak9853
    @claybizjak9853 Před 3 lety

    Thanks for the insight Tim. You set the benchmark, here and all your other videos I've watched.

  • @jbli19
    @jbli19 Před 4 lety +1

    Thank you very much! By watching your video I now understand Unit testing so much better. Keep up the good work.

  • @gerrycallaghan5519
    @gerrycallaghan5519 Před 5 lety +3

    Thanks Tim. Again! You explained material in more depth (for free) than paid course in Udemy I took.

  • @yashsindhwani
    @yashsindhwani Před 4 lety +4

    Thankyou for this video. I have implemented most of the concepts taught here in my company's code.

  • @BambooBob
    @BambooBob Před 3 lety +2

    Back in '93 when I started my programming career, we built our requirements using Test Cases. Then we built the code using the Test Cases. Later, when Test script tools came along, Test Data was stored separately and 'pulled' into the test script. It allowed for a much easier and larger test bed.
    It's true as you said, you can go overboard with your testing. I basically test upper and lower bounds, test data types, test Nulls, and finally test real--life scenarios (using recorded scripts).

  • @abyshekhar
    @abyshekhar Před 3 lety

    This video not just covers unit testing but also the way we extract and extract and extract following Single Responsibility Principle and Clean Code. Thank tou Tim Corey

  • @movsar42
    @movsar42 Před 3 lety +1

    This one is like attending a psychologist, thank you so much, I've been programming more than 10 years but learned about testing only recently, same with design patterns, all because I usually programmed alone and never cared about what others are doing, but now I feel like incompetent which hinders me even at employment, though I decided to go through all your learning path videos and fix this ))
    Thank you!

  • @phelipelima4230
    @phelipelima4230 Před rokem +1

    your videos are great tim and you have such a likeable personality, it feels like a friend is teaching me

  • @anguruso
    @anguruso Před 4 lety +3

    Tim Corey you have done an excellent job. Thank you very much. Hopefully I will pass the coding interview assessment I am about to do

  • @davidshepard8672
    @davidshepard8672 Před 5 lety +1

    great tutorial. Very easy to understand having done no unit testing up until this point

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      Glad it was easy to understand. Going to start doing unit testing now?

  • @Robotron2084Guide
    @Robotron2084Guide Před 8 měsíci +2

    Thank you for this one, as well! One note, being 5 years later, adding the project as xUnit Test Project, allows for selection of newer .NET versions. Using the Class Library (.NET Framework), doesn't allow going beyond .NET v4.x. Which slightly changes how to add the project references from Dependencies>right click>Add Project Reference.

  • @SrinubabuRavilla
    @SrinubabuRavilla Před 4 lety +1

    Tim, thank you for the best video. You explained very well.

  • @surajwankhade9238
    @surajwankhade9238 Před 3 lety +1

    Thank you Tim! You make things look easy.

  • @kylekeenan3485
    @kylekeenan3485 Před 2 lety

    This was amazing and far clearer and easier to understand than other videos which basically just cover an add method.
    Would have like to see a fully fleshed out suite of tests for 1 method though. I'm curious if you would test things like if an argument was null etc even though it would normally be handled on the front end before it reaches the back end code for example.

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety

      I test the things that can happen. If there is no way for that to happen, I probably wouldn't test for it. Although, that's probably a rare case. Usually, I plan for that eventuality in my code so then I test for it.

  • @jameswebdevelo9328
    @jameswebdevelo9328 Před 5 lety

    Thank you! This is exactly what makes this channel so great: 1:05:07

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +1

      You are most welcome. Thanks for watching.

  • @MsGothDoll
    @MsGothDoll Před 5 lety +4

    This is very helpful and amazingly clear explained. Thank you.

  • @radeksendecki9922
    @radeksendecki9922 Před 2 lety

    Tim, your words about TDD fanatics is really important. I (and I guess lot of us) feel I'm not good enough because I haven't written lot of tests in my career.
    That's brings some guilt for me.
    You say 10 is better than 0, 11 is better than 10. That sentence give me a hope and ability to stay calmly focus and slowly building my skills in tests area.
    Thanks you Tim!

  • @FatihYavuz-bq7uc
    @FatihYavuz-bq7uc Před rokem

    Hi Tim, I would like to thank you, Your Videos was very useful for me, I mean not only this tutorial but also almost every videos i watched until now. Thanks again🙏

  • @satishneelakantam7943
    @satishneelakantam7943 Před 5 lety

    Awesome tutorial Tim. Thanks for providing this video.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      You are most welcome. Thanks for watching.

  • @chrisogonas
    @chrisogonas Před 4 lety +1

    Tremendously helpful! Thanks, Tim!

  • @rahulek914
    @rahulek914 Před 5 lety

    Really helpful to get going. Thanks for your efforts and attention to important details.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      You are most welcome. Thanks for watching.

  • @samsongoot6364
    @samsongoot6364 Před 3 lety

    This a best tutoreal about unit testing what i have seen, plz add more and more videos about this !!! Thank you so much.

  • @torrvic1156
    @torrvic1156 Před 3 měsíci

    Great lesson! Thank you so much for sharing, Mr. Corey!

  • @SalomeJalaghonia
    @SalomeJalaghonia Před rokem +1

    As always you are at the top of the art of presentation!!!

  • @BlackSunAngel
    @BlackSunAngel Před 3 lety +1

    probs, i really like the way you explain stuff.
    great work with the time stamps aswell

  • @thobiaslarsen693
    @thobiaslarsen693 Před rokem +1

    I recectly was put to work in doing some small projects and testing them in my company where I work as a student worker. They used XUnit, Moq, and Autofixture, and this video is definetly a good start to build upon. Once done, I need to watch something in Moq and Autofixture, but this really makes things easier :)

  • @250miles2
    @250miles2 Před rokem +1

    I might have to subscribe to Tim Corey... (jk - I already did). This course is, what, 4 years old and yet, it's still applicable today. Easily, one of the best intros to unit testing I've ever seen. Thanks for posting this!

  • @fedos
    @fedos Před 3 lety +3

    Great lesson. My only feedback is that it would be great if the provided source code was from the state of the VS Solution from the start rather than after you made the changes so we can learn by actually making those changes ourselves.

  • @emiljohansson3283
    @emiljohansson3283 Před rokem

    Im currently studying to become a fullstack developer. Unfortunately, even though my teachers are very skilled and knowledgeable, they are somewhat lacking in the pedagogic.
    Your videos are amazing complimentary to understand the fundamentals of subjects that I sometimes find hard to grasp.
    Big thank you!

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      I am glad my content has been so helpful.

  • @jaimin_marfatia
    @jaimin_marfatia Před 4 lety +1

    Really helpful video. Cleared my TDD concepts! :)

  • @Axlefublr
    @Axlefublr Před rokem +1

    Great advice on testing! I agree, that it doesn't have to be all or nothing, even some tests can help you out a lot. I have a few tests for my ahk project, for stuff that I wanted to test while developing. It's like 2% code coverage, but those tests definitely help to make absolute sure *that* part of code works. If I didn't have them, it'd be 0% and that's obviously worse. Better to do a bit than no bit!

  • @stevenvillarreal8970
    @stevenvillarreal8970 Před 3 měsíci

    WOW, Amazing video! This was really informative on how to create and execute XUnit tests!

  • @JayadevNelli
    @JayadevNelli Před 6 lety

    Great video, Thank you for posting !!!

  • @paullee3660
    @paullee3660 Před 5 lety +4

    Blimey! You got up early in the morning to do this video.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +4

      Actually I stayed up late. My window to record (when the house is quiet since I don't have a dedicated soundproof studio) is between 10pm and whenever I'm done. Usually that means midnight or 1am but sometimes it goes longer.

  • @damienk777
    @damienk777 Před 6 lety +1

    I was waiting for this video a long time! :D

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +3

      It has been a long time in coming. I wanted to get it right.

  • @lD3STlNY
    @lD3STlNY Před 4 lety +2

    Hi Tim, great video as always! :d
    I have seen multiple videos where you hard coded the name of a property, so i think you missed a cool feature of c#, since c# 6, you can use the "nameof()" keyword to get the name of a type or member as string at compile time (ie. namof(Person.FirstName)) so the code will not break if you rename FirstName to something else.
    There is a similar keyword called "typeof()", which you can use to get a compile time Type variable, and you can even use it on T types.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +1

      I believe this video (and I know quite a few others were as well) was done before C# 6 came out (or at least I wasn't using it yet). I did miss it on a few videos after it came out but I do use it now and love it! Thanks for bringing it up.

  • @JALEMYmeservey
    @JALEMYmeservey Před 5 lety +5

    Thanks for the video! I'm just starting to get my feet wet with unit testing after a couple years of programming. I've been running into situations where I've changed code and things break. My applications are complex enough where it would be quite a pain to try and manually test for possible errors. It's also rather difficult to think of every possible thing that can go wrong when I make a change. It's nice to build tests that continue to run automatically as the application is built so that I don't have a growing list of things to check for before I deploy updates.
    One small thing I've noticed in your videos is that there is a slight delay between the video and the audio. I'll see the cursor (blinky text editing thing) move on your screen then about half a second later I'll hear a mouse click. It would nice if the audio was perfectly in sync with the video. It's slightly distracting, but not a huge deal. Great videos though. Probably the best on the internet for learning code as far as I'm concerned.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +1

      I've noticed that issue and corrected going forward (mostly). There is a bug in the software I use to record that sometimes allows it to get out of sync. I haven't tracked down why yet and it only happens occasionally now but I try to fix it when I catch it in time.

  • @The_Trucker_Gamer
    @The_Trucker_Gamer Před 4 lety +13

    Thanks for putting this video up I'm trying to learn this and it's so hard to understand for me. Liked and subscribed.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +2

      I am glad the content has been helpful for you.

    • @The_Trucker_Gamer
      @The_Trucker_Gamer Před 4 lety

      @@IAmTimCorey I have to keep rewatching until I get it. I tried testing some methods today and I couldn't figure out how to make the test pass. I am lost.

  • @compman73
    @compman73 Před 3 lety

    Really enjoyed the way you described it, unlike lots of example with simple scenarios
    Thank you

  • @dyachenkoserj
    @dyachenkoserj Před 5 lety

    Thanks. Awesome tutorial, as usual

  • @denniedeclercq5872
    @denniedeclercq5872 Před 10 měsíci

    Really helpfull and great course! Thanks Tim Corey!

  • @olaviosa
    @olaviosa Před 5 lety +1

    Superb! Thanks Corey! :)

  • @ravishchauhan1
    @ravishchauhan1 Před 3 lety

    Great video sir. Thank you so much for making our life easy.

  • @n9434178
    @n9434178 Před 6 lety +2

    Great video - as always! You really help me learn to write much better code. Thank you so much! Will you show different forms of testing in upcoming videos (i.e. end to end testing or more advanced unit tests)? That would be really helpful!

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +4

      Yes, I will be covering other testing types in future videos. First I want to cover more about unit testing though (mocking is the biggest area to cover yet).

    • @n9434178
      @n9434178 Před 6 lety

      I had not heard of that term before in this context - so I am looking forward to learn more...

    • @asyncawake9011
      @asyncawake9011 Před 6 lety +1

      The video was very helpful as usual, thank you!!
      I'm looking forward to learning about mocking and perhaps also how to test private methods with XUnit (as I'm unsure all my smaller "helper methods" should be public just to make them easily testable.. That would go against my attempts at encapsulation. But I do want to test them.). I'm also looking forward to an intro to integration and end to end testing sometime in the future but I know you get a LOT of video requests.

  •  Před 3 lety

    Thanks for the video Tim!

  • @stheday1
    @stheday1 Před 3 lety

    Great intro to unit testing. Thank you.

  • @matuszaprazny
    @matuszaprazny Před rokem

    Great tutorial, thanks Tim!

  • @xxh7595
    @xxh7595 Před 2 lety +1

    Opinion on Unit Testing is doooooooooope. Nice speech.

  • @tao5198
    @tao5198 Před 2 lety

    A great video for introduction to unit test, Thanks!

  • @mokhan1676
    @mokhan1676 Před 4 lety +3

    wow. recently started a new job and was a bit overwhelmed with the unit testing and mocks but found this video extremely helpful. I feel a little more confident about them now. Thank you so much! subscribed :)

  • @ben.thornhill
    @ben.thornhill Před 5 lety +2

    Thank you sir, as always.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      You are most welcome. Thanks for watching.

  • @xianyu6565
    @xianyu6565 Před 4 lety +2

    Thanks for the detailed walkthrough! A question, what if I just want to check whether an exception is thrown, and don't care about the exception type? Asset.Throws seems to work with the specific type only.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +1

      Check for the type of Exception. Since all exceptions derive from Exception, that should give you what you need.

  • @jpeisleide
    @jpeisleide Před 2 lety +1

    Thank you for sharing this course!

  • @xeyalteyyubov1175
    @xeyalteyyubov1175 Před 2 lety +1

    I Appreciate it, man. You are awesome.

  • @joerattz
    @joerattz Před 5 lety

    Excellent video! I like that xUnit Theories allow me to test multiple inputs with the same code, thereby lowering my test code to real code ratio (one of my fears with unit testing).
    Also, as a tip for others, in my methods for Theories, I prefer for the expected value to be the first parameter (as opposed to last) to handle methods I'm going to test that accept a variable number of parameters via the params keyword.
    For example, if I were going to test the String.Format method, I would like for my test method to have a signature like:
    public static void Format_Theory(string expected, string format, params object[] args)
    You can't really do it any other good way that I know.
    This way my unit tests will be consistent in terms of where the expected argument is going to be in the signature.

  • @timurmakimov5491
    @timurmakimov5491 Před 3 lety +5

    It would be great to have a tutorial on the subject of Unit tests VS Integration tests and how to use Dependency Injection to isolate units and convert Integration tests to Unit tests

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety +3

      Added to the list of suggestions, thanks

  • @antoniomarcos5664
    @antoniomarcos5664 Před 4 lety

    Thank you a lot, Tim.

  • @tondar2127
    @tondar2127 Před 3 lety

    Thank you so much ! very nice explaining !

  • @austinmudadi9178
    @austinmudadi9178 Před rokem

    Thanks Tim, you the best!

  • @RaterisimoCBA
    @RaterisimoCBA Před 2 lety +2

    Great video Tim, first time I get into unit testing and I really like your slow / calmed pace of teaching, the pauses you make are key to be able to graps the concepts of what you're explaining. I will be doing the homework on this project now :)

  • @facundovega1726
    @facundovega1726 Před 3 lety

    Thanks a lot for such amazing video!

  • @KiranYadavOG
    @KiranYadavOG Před 9 měsíci

    Thanks for this! Enjoyed it!

  • @flyingsuqirrel1433
    @flyingsuqirrel1433 Před 2 lety +1

    Hi Tim, I really appreciate your work and hope to get a little update on TDD. Do you use the xUnit template for new projects? And can you give a hint, when to create a new Solution? Right now I am struggling whether I should put everything in one Solution or split the UI into a new one.

  • @augustobarreto5301
    @augustobarreto5301 Před 2 lety

    Thank you for this video, it really helped me a lot!

  • @SuperEvoken
    @SuperEvoken Před 2 lety

    great video, just what I needed.

  • @adewaleayeseteminkan4201

    This is super cool and well explained. Thanks so much..

  • @axlecy
    @axlecy Před 6 lety

    Great Video, thank so much !!!

  • @GonzaloRMDT
    @GonzaloRMDT Před 4 lety

    Great explanation! Thanks.

  • @oleksiimykhailenko258
    @oleksiimykhailenko258 Před 2 lety

    Very cool! As always. thanks a lot!)

  • @maheshyarasi2939
    @maheshyarasi2939 Před 3 lety

    Thanks so much for the video Tim! I was wondering is it possible to have the Assert statement return a value? As in if I want to store the pass fail result in a variable, how would I do that?

  • @adriano.digiere
    @adriano.digiere Před 3 lety

    Fantastic. Thanks Tim

  • @brianwells990
    @brianwells990 Před 5 lety +3

    Enjoying your video! Thank you! Apologies if you explained this, I'm only a few minutes in... was wondering why it was so important to start the xUnit project off as a .NET Framework and not a .NET Standard library?

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +3

      Couple reasons First, .NET Standard has some limitations that the .NET Framework does not. Second, it makes it easier to follow along if you use the same type as I do.

  • @edvardpotapenko
    @edvardpotapenko Před 4 lety

    thank you, great explanation

  • @bibekkhatri
    @bibekkhatri Před 3 lety

    Best tutorial on Unit Testing with Xunit. ❤

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety

      Glad you think so!

    • @bibekkhatri
      @bibekkhatri Před 3 lety

      @@IAmTimCorey Sir, please can you make a tutorial on NHibernate?

  • @arthinkers
    @arthinkers Před rokem

    Tim, I miss the old way of coding where it is a lot cleaner, not much of hidden Freebies, anyway, this is the best ever simple coding on how to properly use XUnit. I hope you would also teach about MSTest in CI/CD on how it differs to XUnit Tests. Super THANK YOU Sir!

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +2

      Not sure what you mean by "hidden freebies", but I am glad you enjoyed the video.

  • @aimanemeish3482
    @aimanemeish3482 Před 3 lety

    thank you very match, very helpfull and great advices

  • @Bloodthirst
    @Bloodthirst Před 5 lety +1

    hey i saw that sneaky Unity3D icon on your desktop , good to know that you are having fun with C# in Unity :)

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +3

      Unfortunately, that isn't my desktop. For that video I had to demo Visual Studio 2017 Community Edition because I use Enterprise Edition and EE has more features for Unit Tests than CE does and I didn't want to show people things they couldn't do. So I used a virtual machine in Azure as my desktop (the cloud is just so convenient). Unfortunately, I just haven't had the time to play with Unity. I would like to some day but .NET Core comes first.

    • @leoingson
      @leoingson Před 4 lety

      @@IAmTimCorey Could you give me some quick pointers how to set up said VM in Azure? Do I need a paid Azure account/space? Could I start it locally in VirtualBox (or similar)? I ask since I work on a Mac using vs2019, and sometimes get suckered into using WinForms/WPF/older VS/MS-SQL ...

  • @christianista
    @christianista Před 6 lety +1

    A good idea should be talk about "Integration Tests" (Facade => Service => DB, no mocking). Useful when you use "Dapper" (but not only) where you can do a typo easily.

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +4

      Yeah, some more advanced, real-world examples of unit testing are on the roadmap. The whole idea of mocking, stubs, fakes, and all the rest are in there too.

  • @LilPozzer
    @LilPozzer Před 3 lety +1

    Thank you, Tim!

  • @krishpatil80
    @krishpatil80 Před 3 lety

    Thanks Tim!!

  • @mihowbogucki4928
    @mihowbogucki4928 Před 5 lety

    Fantastic video!

  • @shsoshoshosho7386
    @shsoshoshosho7386 Před 3 lety

    Hi Tim, thank you for the video it was helpful.
    This is the first time that I am trying to unit test my project. it's a Windows forms application. I couldn't figure out how to design the tests because I have the following issues:
    1) most of my methods are void
    2) some code uses database values or records
    3) the methods are events that are triggered by controls like buttons or radio buttons
    if you have any suggestions regarding these please assist me.
    Thank you

  • @movsar42
    @movsar42 Před 3 lety

    Thanks for the homework!

  • @paulofernandoee
    @paulofernandoee Před 2 lety

    Very good content, thanks!

  • @ibrahimhebish1404
    @ibrahimhebish1404 Před 3 lety

    Thanks Tim it's very informative

  • @tonyocnos6691
    @tonyocnos6691 Před 3 lety +1

    Hi Corey! Your videos are just...GREAT! LOVE THEM ALL! Just a simple question: is it necessary to build the solution each time you wanna run a test case? In my case it does not throws an error if I do not build the solution once again, but I would like to know in which case that may happen.

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety +1

      You only need to do a rebuild if the code has changed.

  • @refactorear
    @refactorear Před 4 lety +1

    Hi Tim, been following you for a couple of weeks by now and I'd like to leave a couple of notes based on experience. Following a TDD approach I'd have written the test first for the DataAccess class instead of refactoring because (supposing it's a real life situation where your DataAccess is actually working) you wouldn't be sure if your class continued to work after the refactoring.
    The other thing is that your testing approach would only work with classes that are more structured-oriented or functional-oriented than object-oriented (for example, classes with lots of public methods that are either static or don't keep instance attributes). In real object-oriented unit testing the smallest unit of code to test is not a single method but the class as a whole calling the minimum amount of methods required for the class to work (for example in a BankAccount class the minimum unit testing could be create the account, deposit a small amount of money, request the balance, withdraw the money and close the account). This is a mistake done by many (if not most) programmers wanting to start unit testing and also TDD supporters. And no, I'm not one of those mad zealots :) but if you test only a method in a class that had 5 instance attributes you will virtually skip every state where the attribute work for your tested method but breaks every other method.
    Best regards

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +1

      I tried not to go down the TDD road because if you are just learning unit testing, you probably have existing code that needs to be tested. As for the working with classes instead of methods, this sounds more like integration testing than unit testing. You can test the individual methods and just identify the various inputs and outputs where a changed value occurs and then test to those values.

  • @amirdar
    @amirdar Před 2 lety

    He's recording it at 5 AM. respect!

  • @uwemueller1918
    @uwemueller1918 Před 3 lety

    Wow, Wow, Wow... Thank u very much for the great work! [Opinion on Unit Testing]-> enlighten.

  • @CodySchichtl
    @CodySchichtl Před 4 lety

    Great stuff!

  • @hardryv3719
    @hardryv3719 Před rokem

    Excellent presentation