There are actually people claiming you shouldn't do unit test on private method ? what bullshit is this ???

#programming

@Ambraven Are they the same people who claim that unit tests are only useful for refactoring?

@jkb

I'm not sure. They say "if you have to test a private method you should refactor" but I don't think it counts as "only useful for refactoring".

Also it's bullshit.

Follow

@Ambraven So basically black box testing where only the spec is checked not the implementation code? That's a way to cut effort

@jkb

I'm beginning to think that some rationnailsation for old c++ users that can't test privates in a clean way so they decided it was bad practice actually.

@Ambraven @jkb For a properly designed type, if a method preserves the invariant it should be public, therefore private methods do not preserve it. Unit tests should verify and document invariants, not specific ways in which some intermediate step in the implementation happened to break them. This might not seem generally applicable, only because crippled (invariant preserving private methods) and leaky (invariant breaking public methods) interfaces are common place and standard practice.

Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!