java - How to write a junit testcase for a void method that creates a new object -
public class supportcontroller{ public void disableuseraccount(string username) throws exception { useraccount useraccount = new useraccount(constants.system, constants.container, username); useraccount.disableaccount(); } }
how test useraccount created disabled?
i suggest using mock objects.
besides that, can check junit faq, can find section testing methods return void
.
often if method doesn't return value, have side effect. actually, if doesn't return value , doesn't have side effect, isn't doing anything.
there may way verify side effect occurred expected
Comments
Post a Comment