mercredi 25 mars 2015

Unit testing some methods that aren't required by outside objects.

I have my database layer:



public class DataBaseLayer
{
public Result runQuery(Query q)
{
this.openSession();
this.runPackage(q);
Results r = this.fetchResults();
this.closeSession();
return r;
}

}


Currently all those methods are private methods.


But I want to be able to test them.


for example



private void testOpenSession_wrongUserNamePassword_returnsBadUserNamePassWordError();
private void testrunPackage_insufficientPrivileges_returnsInsufficientPrivlegesError();


The question is what's the nicest way of doing this?


I figure I could either:



  • Just test the runQuery method for bad username password etc.

  • Make those methods protected.

  • Make those methods public.


Aucun commentaire:

Enregistrer un commentaire