Skip to content

How to test protected properties? #228

Answered by egil
MiBuena asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MiBuena,

This is less of a bUnit question and more a question of testing strategy in general.

My gut feeling is that if something is non-public, its an implementation detail that you should not be writing your tests against. If you do, you tie your tests very tightly to an implementation detail that you might want to change later without breaking your tests. Internal refactoring of a component under test that does NOT change its output or observable behavior should no be breaking tests.

If it is an important business requirement that the Items list contains certain items, I would instead ask why it is protected in the first place? If it is important, then it likely also needs to be pu…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@MiBuena
Comment options

@egil
Comment options

@MiBuena
Comment options

Answer selected by egil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants