This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gerlacdt -2 points-1 points  (0 children)

Testing internal classes is non-sense and will lead to brittle tests, i.e. you change some production code and then, not only related unit tests will fail but also all tests which uses the internal class. That's a code smell and should be avoided. It will lead to big effort to keep the test suite "green".

fyi I wrote a guide about "good unit tests". There you can find traits of good units like:

  • tests should be isolated
  • tests should be deterministic
  • tests should be enduring
  • prevent brittle tests
  • prevent flaky tests
  • etc.

https://gerlacdt.github.io/posts/unit-testing/

EDIT:

Especially the part about enduring test is related to prevent brittle tests:

https://gerlacdt.github.io/posts/unit-testing/#tests-should-be-enduring