Testing Private Functions? The Why and How!

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 9

  • @dusilva3796
    @dusilva3796 5 місяців тому

    Your playlist abou tests seems very cool, I am goin to be watching ot soon.

  • @KalpeshDoru-hn6oo
    @KalpeshDoru-hn6oo Рік тому +1

    Helpful, Thank you

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

    Informative.

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

    Thanks, great help. Will use this

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

    Thanks for the video, one question, will this add line coverage to the private function?

  • @eric-wubbolameijer9558
    @eric-wubbolameijer9558 Рік тому +1

    I suppose @VisibleForTesting may be a useful tool in some circumstances, so thank you! However, in this particular case (have you ever read Khorikov's book on unit testing?) I would tend to say that the code to be tested has poor separation of concerns: I would usually indeed have some kind of Formatter class (or extension function) and test that, and let the presentation of the message (here, to the console) be done by another class. After all, as developers we usually have specific classes for IO (like controllers, or repositories, or filewriters), so separating the possibly complex and hence useful-to-test business logic from the 'plumbing' of IO would make sense.

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

      Yeep exactly, this is just a simple example that would help me demonstrate my point and the way to achieve private function testing WHEN needed.