C# Unit Testing Tutorial For Beginners

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 15. 06. 2024
  • đŸ’»Get the source code: go.dotnetacademy.io/unittesti...
    đŸ”„Check out the Full Course: juliocasal.com/csharp-unittes...
    Learn how to write unit tests for your C# applications so you can catch defects early, refactor with confidence and ship your code faster.
    đŸ”„Become a Senior C# Backend Engineer: juliocasal.com/courses
    đŸ—șGet My Free .NET Backend Developer Roadmap: juliocasal.com/roadmap
    Join me on Patreon: / juliocasal
    Follow me on LinkedIn: / juliocasal
    Follow me on X: x.com/julioc
    #unittesting #csharp #dotnet

Komentáƙe • 12

  • @luisfernandodeolazabalsche3317
    @luisfernandodeolazabalsche3317 Pƙed měsĂ­cem +1

    Muchas gracias Julio.

  • @donnyroufs551
    @donnyroufs551 Pƙed 7 měsĂ­ci +1

    I wouldn't perse agree with "Verify a small piece of code" A unit can be completely isolated or talk to multiple components. If we look at the definition given by M. Feathers then it is not a unit test when:
    - It talks to the database
    - It communicates across the network
    - It touches the file system
    - It can’t run at the same time as any of your other unit tests
    - You have to do special things to your environment (such as editing config files) to run it
    I am not sure where it exactly went wrong but unit tests are really misunderstood leading to testing implementation details instead of observable behavior. If you take your traditional layered application then I could still be writing a unit test at a controller level going all the way through my service and repositories. Now that doesn't take away that you can test something in isolation (which you have shown) but it surely creates a fragile test suite when overdone.
    Vladimir Khorikov has a great book on this imo.

    • @juliocasal
      @juliocasal  Pƙed 7 měsĂ­ci

      From Vladimir's book:
      "A unit test is an automated that verifies a small piece of code (also known as a unit), does it quickly, and does it in an isolated manner"

    • @donnyroufs551
      @donnyroufs551 Pƙed 7 měsĂ­ci +1

      @@juliocasal sorry my reference to vladimir was about the different types of unit tests. Not perse his definition of a "unit" (which I actually cannot recall). In his book he mentions at least 3 different types, where one is related to collaboration which in fact does not mean that you specifically test a small piece of code and thats one where we tend to refer to integration tests which isnt really the case.

  • @azraiqbal187
    @azraiqbal187 Pƙed 6 měsĂ­ci +1

    Hi Julio, do you have any plan to add unit and integration testing sections in your microservices course?
    It would be very helpful.
    Thanks.

    • @juliocasal
      @juliocasal  Pƙed 6 měsĂ­ci +1

      Here: juliocasal.com/csharp-unittesting-essentials

    • @azraiqbal187
      @azraiqbal187 Pƙed 6 měsĂ­ci

      @@juliocasal I know you've launch a course on unit testing, but I'm talking about the microservices course.
      Does microservices course cover the unit testing of code which we write in that course? Or any zip file in the section that included unit testing code for the course?

    • @juliocasal
      @juliocasal  Pƙed 6 měsĂ­ci +1

      @@azraiqbal187 No, unit testing is a broad topic that needs its own space. Everything I know about unit testing is now in my unit testing courses.

    • @azraiqbal187
      @azraiqbal187 Pƙed 6 měsĂ­ci

      @@juliocasal Thanks for responding 🙂

  • @rakibjahankhan4656
    @rakibjahankhan4656 Pƙed 7 měsĂ­ci +1

    Is there any public git repository of the GameLibrary full project with unit test?

    • @juliocasal
      @juliocasal  Pƙed 7 měsĂ­ci

      No, full source code is available in my Patreon community: www.patreon.com/juliocasal