How Do You Test A Method That Does Not Return Anything

How Do You Test A Method That Does Not Return Anything


  • 20 Jan, 2012

    You need to follow the logic below to answer this question: * If a method is not returning anything through the "return" statement (void method), it may return data through its arguments. In this case, you can test the data returned in any argument. * Else if a method is not returning any data through its arguments, it may change values of its instance variables. In this case, you can test changes of any instance variables. * Else if a method is not changing any instance variable, it may change values of its class variables. In this case, you can test changes of any class variables. * Else if a method is not changing any class variable, it may change external resources. In this case, you can test changes of any external resources. * Else if a method is not changing any external resources, it may just doing nothing but holding the thread in a waiting status. In this case, you can test this waiting condition. * Else if a method is not holding the thread in waiting status, then this method is really doing nothing. In this case, there is no need to test this method. :-)

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.