I am very new to junit.I was reading a tutorial on http://docs.spring.io/spring/articles/2007/Spring-MVC-step-by-step/part1.html for spring mvc and I found a test class as below :
1.)
package springapp.web;
import org.springframework.web.servlet.ModelAndView;
import springapp.web.HelloController;
import junit.framework.TestCase;
public class HelloControllerTests extends TestCase {
public void testHandleRequestView() throws Exception{ HelloController controller = new HelloController(); ModelAndView modelAndView = controller.handleRequest(null, null); assertEquals("hello.jsp", modelAndView.getViewName()); } }
I can not understand why I need to use TestCase of Junit as an extra burden when I can check the same by creating a simple test class.
public class TestStub {
public static void main(String[] args) {
HelloController controller = new HelloController();
ModelAndView modelAndView = controller.handleRequest(null, null);
if(modelAndView.getViewName().equals("hello.jsp")) {
...
}
}
}
Again mentioning that I am a beginner.