mardi 21 juillet 2015

Test the behaviour of concurrent code

I have an object which after receiving some message changes state asynchronously (an internal thread changes the state). After the state changed I want to test some behavior.

So basically I need to do something like:

  1. Create object
  2. Send message to object
  3. Wait for state to change
  4. Test behavior

However, the state is private and not exposed.

Is there an elegant solution to this that does not require exposing the state?

And if not - is it reasonable to require changing the main code just to make it more testable?

Aucun commentaire:

Enregistrer un commentaire