How do I test a method that returns void?

Mike Clark

Test an expected side-effect of the method. This may involve querying an instance variable or passing in a mock object to collect the results of the method. The latter is sometimes useful to avoid breaking encapsulation.

Also consider changing the method so that it returns a value that can be asserted.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact