vendredi 20 novembre 2015

Make method only callable from unit test

Is it possible to write methods, which are only callable by unittests? My problem is that our framework contains a lot of Singleton classes, which makes unit testing quite hard some time. My idea was to create a simple interface like this:

public interface IUnitTestClearable
{
    void ClearForUnitTest();
}

This method will be called for "resetting" singleton instances for better handling of unit tests. But this method should only be callable from unittest classes/instances. Is this possible?

Thank you very much!

EDIT

If my idea is completly stupid, please let me now.

Aucun commentaire:

Enregistrer un commentaire