jeudi 28 janvier 2016

What's the best practice for testing public methods that use private variable?

So I have a class with 2 public methods init() and doStuff(). init() sets up a private variable $_myPrivVar. The doStuff() method uses this variable.

When writing unit tests for doStuff() what's the best practice for setting up $_myPrivVar? Presumably I don't want to use init() to do it as my unit test is suddenly testing 2 units of code?

This is a contrived version of my real world scenario.

Aucun commentaire:

Enregistrer un commentaire