You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Vic Cekvenich <vc...@basebeans.com> on 2003/02/06 01:14:02 UTC

Unit Test Was Re: Need help deciphering screw-case for PR 15799

James Turner wrote:
> 
> 
> I have major problems (both for Struts and with my client's projects)
> about regression testing, specifically with JSP.  This is really causing
> problems for us in Struts, because many of the things that are coming up
> are taglib-related and nearly impossible to accurately unit-test.
> 
> I'd love to see a good solution proposed for this, I've tried Cactus and
> it's a good half-way step, but still doesn't really test the code on the
> JSP page.

SNIP

I find most errors are data model changes, etc, that show up as JSP.

A dirty solution I have used successfully :
- be religious about testing! a bean that does not work (unit test) 
outside of Struts, will not start working inside of Struts/JSP. A bean 
must multi row, master/Detail (via nesting), crud, via a DAO helper, etc.
  A beans "contract" is the JSP fields.

- I create an abstract String TestIt() method in "baseFormBean". It 
extends validatorformbean. (I avoid Dynabeans because I can't test it, 
hence it is risky. Also somtimes I do use bean Model 1 style or 
JavaScript, or Soap, or c:tag, or display tag, etc. So I just like plain 
bean.)
- People write retrieve, update, insert, getters methods in concreate 
beans, they must; it won't compile -it's abstract.
- I have a servlet that does new of every bean, and does testIt.
- I check the log, and see any fatal or error's, the regresion failed! 
log info just shows the data before and after Crud. Multi row CRUD as 
well (another topic, but "my" formbeans implement collection in base, 
and nesting them makes it Master/Detail. Of course, you can have 2 sets 
of beans and copy)
-The formBean must match the JSP needs, that that is what you unit test, 
the "contract" of the JSP; I program to requirments. A client can make 
up any HTML they want, I rename file to JSP; that is my contract! Now I 
write the unit test (testIt) and go back to write a DAO instance to help 
me get the data (clients don't care about how I get the data or where it 
is, neither does my bean)

Also: When clients ask me for tech support on JSP, I say, show me the 
output of the testIt log "file" for that formBean. Bingo!

To place a tested bean in Struts is trivial!
To run testIt() servelt, that tests all the beans, is trivial. You can 
even have the servelt fire at 5PM every day (via web.xml)
Source is in basicPortal, should you want the quick/dirty.

I do not think the testing tool is important, once you grasp that unit 
testing speeds development.
Hard time I have is managers saying, we are on a short deadline, we do 
not have time to test..... of course, the shorter the deadline, the more 
testing you need. Which is what a consultant does, shows them how to 
shave time.

I do not know how to test a JSP, nor do I have major erros there. Mostly 
JavaScript errors... yuck!

.V



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org