Hi, During one interview, the interviewwer asked me 'How to testJSP?' Normally I write a JSP and directly test it on Tomcat. But he said it is a wrong and lengthy method to track any error from tomcat. Is there any other way? Also suggest me ways of testing EJB?
Can't test JSP, was a trick question. He was bullshitting you, The Enterprise Arch. and my job always tells us not to place heavy code inside JSP, but in Servlets because you can only test a JSP at Deploy time. OR, You have a JSP tester inside your IDE that will run and debug the JSP for you. EJB? same as above, you have a reference or developer version of the App Server on your local machine that is controlled from within the IDE So the IDE loads, invokes and debugs the EJB or JSP for you(IN A WAY) thats it IF he was talking about adding the jasper engine to you build and actually invoking it without a Servlet Container, He must have been nuts. That was an unfair and useless question. A more important question would be how do you handle and test for JSP Exceptions? How do you force JSP Exceptions to be handled/debugged to facilitate testing? Everybody knows that the achilles heel of JSP and EJB is deployability.
I know next to nothing about JSPs (I've read the specs and other documentation about 3 years ago, but have never used them). Nonetheless, I would assume that, because it creates a display , you can do some type of GUI testing. I can imagine a robot which enters text in text fields, and clicks buttons, just to insure that such widgets are present in the display. It may be semantics whether this is JSP testing or GUI testing, but I would think this type of test would be possible. Of course, he was probably hoping to hear an answer along the lines of Cactus. --Mark