C# Unit Tests Using NUnit (.NET) (Beginner)

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 42

  • @MatthiWare
    @MatthiWare  3 года назад +5

    You can find the source code for the unit tests here
    github.com/MatthiWare/UnitTesting/tree/starting-point

  • @kopilkaiser8991
    @kopilkaiser8991 Год назад +3

    Simple but yet informative and your video covers basically all that is needed to know about NUnit Project unit testing. I was a bit confused but thanks to your tutorial, it made things more easier to understand. Keep up the good work.

  • @carlramirez9707
    @carlramirez9707 Год назад +1

    I have been seen multiples videos for many years. This is the first one that I understand the all explanation. To be honest, you are so good doing this. Congrats!

  • @UsaSzerelem
    @UsaSzerelem 11 месяцев назад +1

    Thank you for this tutorial. It was helpful and glad to see that this course can still be completed without errors after two years.

  • @studs4eva16a8
    @studs4eva16a8 Год назад

    Thanks Man. You made it quite simple to understand & very well planned.

  • @aaronzheng519
    @aaronzheng519 3 года назад +1

    love the video..following the steps and actually I'm understanding what it is trying to do now.thank you! never write unit test and I'm expecting to have an interview to cover that.LOL

    • @MatthiWare
      @MatthiWare  3 года назад

      Good luck with the interview and I hope this video helped!

  • @antonyndungu5514
    @antonyndungu5514 3 года назад +3

    Awesome video, explanation is simple and clear

  • @blissweb
    @blissweb 2 года назад

    Awesome video ! for us old dinosaurs / cowboys who are now being forced to do unit testing ;-)

  • @MatthiWare
    @MatthiWare  2 года назад +1

    Use Mocking in C# .NET Unit Tests ruclips.net/video/jkzJwTbcSRg/видео.html

  • @dhruvpatel6604
    @dhruvpatel6604 2 года назад +1

    Great tutorial learned a lot! Thanks!

  • @SwapnilJadhavVlogsOfficial
    @SwapnilJadhavVlogsOfficial 2 года назад +1

    This was a great tutorial !

  • @karenkostandyan3264
    @karenkostandyan3264 11 месяцев назад

    The best tutorial!

  • @jeffbee6090
    @jeffbee6090 3 года назад

    great introductory video! thanks!

  • @christianmontagx8461
    @christianmontagx8461 2 года назад +1

    Don't know what you are talking about? There is no NUnit for .Net Framework in VS2019 default installation. That is the part on minute 2 where you stumble upon.

  • @Antonov_Woody_Nikolay
    @Antonov_Woody_Nikolay 2 года назад

    Very usefull video, thanks.

  • @Monkey-on7iz
    @Monkey-on7iz 3 года назад +1

    Hi, what type of project of Bank? Is it "Class library" or "Console application"? How can I create "Console application" and link it with project of NUnit test.
    I was repeating after you and create project "Bank" as "Console Application" then I create project of NUnit test, then clicked on project test and added reference to "Bank". But when I tried to create instance of "Bank" my test method didn't see Bank class

    • @MatthiWare
      @MatthiWare  3 года назад

      Make sure the Bank class is public and also make sure you added the namespace of the Bank class. If you still have issues you can find the complete code here: github.com/MatthiWare/UnitTesting/blob/master/BankNUnitTests/BankAccountTests.cs

    • @Monkey-on7iz
      @Monkey-on7iz 3 года назад

      @@MatthiWare thank you so much, I tried to figure out how to set it up for three days. But mistake was in directive of using, I forgot to write it in project, but actually I didn't know that I must to write it

  • @nikkilovesdannyfull
    @nikkilovesdannyfull 3 года назад

    Thank you for the information!

  • @shinyshark2247
    @shinyshark2247 2 года назад

    Hello Matthi, thank you for the wonderful video. It was very helpful to get me started. I have an issue that I find difficult to solve though. I want to run a unit test on a private method. When I Arrange the class to test on, I cannot call the private method because it is private to that class. I know I could make it public, but I would rather not do that. What could I do in Unit Testing to test a private method?

    • @MatthiWare
      @MatthiWare  2 года назад +4

      Hi, making the method public is indeed not a good idea. What you'll need to do is test the public methods that call the private methods. Best case would be that by only testing the public method(s), you also tested all possible code paths in the private method(s).

  • @ecaepevolhturt
    @ecaepevolhturt 3 года назад

    Which NUnit packages did you install. I installed "NUnit" and "NUnit3TestAdapter". When I try to run the test, nothing is displayed in the "test explorer". I'm using "VS2019 community". Can you give me any advice? Great tutorial btw!

    • @MatthiWare
      @MatthiWare  3 года назад

      Hi that should be correct, you can double check with the ones I used here github.com/MatthiWare/UnitTesting/blob/master/BankNUnitTests/BankNUnitTests.csproj or try out my finished project in the github repo locally and see if that works. I've also had troubles with running tests a couple of times but normally there should be an error log in the console of visual studio, you can use that message to find a solution on stackoverflow for example. Good luck trying to resolve the issue!

    • @ecaepevolhturt
      @ecaepevolhturt 3 года назад

      @@MatthiWare Thanks for the reply. I'll try this later. It's such a strange problem. "Test Explorer" can not find the tests. I tried XUnit as well and the same thing happens.

    • @ecaepevolhturt
      @ecaepevolhturt 3 года назад

      @@MatthiWare WOOHOO! I just got got XUnit working. All I had to do after re-installing packages was to close VS and restart my computer. I think it was a combination of things, one being my CPU being overloaded. I think it's time to think about buying a new laptop for development. Thanks for your help!

    • @MatthiWare
      @MatthiWare  3 года назад

      @@ecaepevolhturt No problem, glad I could help!

  • @gesjeverair
    @gesjeverair 3 года назад +1

    Very nice video!

  • @luckysana7606
    @luckysana7606 2 года назад

    I write test code for add and subtract but it's give me error can't not be access with instance reference qualify with type name what to do now

    • @MatthiWare
      @MatthiWare  2 года назад

      Hi it seems like you are trying to access BankAccount class. You should access the instance of the BankAccount that you defined. In the tutorial this instance is called "account". If this still doesn't help you can check the complete source code and try to find what you are doing wrong: github.com/MatthiWare/UnitTesting/blob/master/BankNUnitTests/BankAccountTests.cs

  • @pd6335
    @pd6335 2 года назад

    Great tutorial :)

  • @e1.st0rm99
    @e1.st0rm99 2 года назад

    Thank you.

  • @thedembelecoder5776
    @thedembelecoder5776 2 года назад

    hi ,
    plz help me MatthiWare
    How can i order tests (up to 300)

    • @MatthiWare
      @MatthiWare  2 года назад +1

      You can add a [Order(1)] attribute see: docs.nunit.org/articles/nunit/writing-tests/attributes/order.html

    • @thedembelecoder5776
      @thedembelecoder5776 2 года назад

      @@MatthiWare thanx MatthiWare

  • @StayAware9
    @StayAware9 2 года назад

    bro buy a good mic

  • @hemanthsg1546
    @hemanthsg1546 2 года назад

    I'm getting bank.dll could not be found error , and Adding_funds_updates_balance test is failing

    • @hemanthsg1546
      @hemanthsg1546 2 года назад

      How to resolve this ?

    • @MatthiWare
      @MatthiWare  2 года назад +1

      Hi if you are using visual studio, go to build -> rebuild solution. After that you should be able to execute the tests!
      Also check the complete source code here: github.com/MatthiWare/UnitTesting