Fluent Assertions in Unit Testing in C#

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

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

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

    Thanks for the 10 minute format on FluentAssertions. Most of us can spare 10 minutes to learn something valuable.
    I hadn't thought about combining several tests within one unit test via AssertionScope(). It's been suggested that I test only one thing per unit test, but that unit definition is elusive. I think I need to be more pragmatic here. A "unit" does not need to be so fine grained. Thanks for reminding me of that.

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

    Great video. I need to go through your unit testing ones to make myself familiar with these processes

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

      Thanks!

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

      @@IAmTimCorey I’m currently an asp web developer but my job wants me to look into more back end code to develop new versions and support our current version for our software. Do you have any videos or advice on understanding code that is already in place with little documentation?

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

    Nice tutorial. Reminded me of NUnit testing framework which has this built in

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

    As always thanks Tim for your videos. Helps me keep up with what's new in C#. Though would love to see some videos on code reviews of projects that you found interesting and what could be improved on them. I think it will help to understand how to deal with new code and improve it. Also thank you for making me love programming ❤️

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
      I'm glad I was able to help instill in you a love for programming.

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

      @IAmTimCorey Thank you Tim, that's a great idea. I will do that

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

    Thanks ! If I might add, although I haven't tested that thoroughly yet, I keep hearing that Fluent Assertions is also one of the most ideal libraries for testing Json heavy functions and objects.. Don't quote me on that though.

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

    is there a c# equivalent for behavior driven development testing? fluent assertions are nice, but I don't know if they are enough.

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

    Thank for this video. In additon to be a great teacher you have very good taste in music

  • @simon-white
    @simon-white Год назад

    Nice, similar language elements to PowerShell's Pester unit testing module.

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

    Nice and simple! Thanks, Tim!

  • @Rajeshsingh-ws5th
    @Rajeshsingh-ws5th Год назад +2

    Very well done by community, and thanks Tim for this.

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

    Is unit testing even worth the effort for more complex types of classes? For instance, if you have a class that takes a number as a property (num). Then it has a property (By512) that multiplies 'num' by 512 and returns the result (getter). Now, imagine there are a dozen properties like "By512" that all do the same thing but have their own static value to multiply against, including integers and doubles. I feel like this type of scenario would require more time writing tests than there's actual code to do the work in the class being tested. Unless I'm not understanding this correctly.

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

      The tests are like guardrails.They ensure we don't stray off the road. As for them taking too long to write, use AI like CoPilot to write them for you.

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

      If any one of those methods stops working the way you want it to, well written unit tests will show you exactly which method is not behaving correctly and why. Otherwise you might spend hours digging through your code trying to figure out why this function isn't doing what you want. Even though the test code may be longer than the code you're testing, 99% of the time it is invaluable

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

    In Dutch your sample would turn out even worse. You should write Eddie van Halen, van in lower case, but as soon as you split it, and only consider the last name, you should write Van Halen, capitalized. Normally in Dutch IT systems Van and Halen would be separate fields in the database, to make this processing easier. It can even get worse with names line Jan van de Berg, where you have two intermediate words. This is a very common Dutch name. It think this makes up for a nice localization issue. It even can be that the customer enters the name like this: Jan vd Berg.

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

      That sounds tricky to deal with.

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

      that's actually a really cool topic, I bet it's quite a headache.

    • @torrvic1156
      @torrvic1156 2 месяца назад

      So how you guys deal with such complicated issues? 😊

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

    Thanks for the video. 😊

  • @OeHomestead
    @OeHomestead 4 месяца назад

    A+ for using Eddie's name :-D

  • @0432sandeep
    @0432sandeep Год назад

    LivingDoc is not reporting the failed tests if the soft assertions are failing.

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

      Sounds like something you need to report.

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

    Thanks

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

    clearly fluent assertions reads better and gives better error messages on failing tests. so is this the future ?

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

      It does make working with failing tests easier.