Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unit testing struts?

 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what do you folks use to unit test your struts app?

StrutsTestCase? (Mock object approach or Cactus approach?)
HttpUnit?
plain Cactus?

I've got a typical Struts app with a DB backend, so can I really test it with Mock objects if I need to be able to ping the DB for data? BTW, I never insert data in the DB with my app, its all just viewing data that already exists in the DB.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I find little need to unit test Struts Action because I do my best to keep business logic out. I try to use Actions just for page flow...
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahhh good point -- all my business logic is in my "helper" methods -- so I guess I can just do straight JUnit tests on those to test. Although I guess I'll need to use some mock objects to handle request / session scopes and stuff, right?
 
Tim Brizard
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jess,
In the past I've used a BusinessDelegate(s) which gets called from my Action class(s). The business delegate does not know anything about servlet classes or struts classes. So, I can write my junit tests without having to create Mock objects, just test the business functionality that is exposed by the methods on the business delegate(s). The business delegate, then uses whatever other classes you have designed (Session Facade, BOs, etc.). This way there is little testing of the Action class that is needed, because you would essentially be testing the Struts Framework. Hope this helps.
[ May 14, 2004: Message edited by: Tim Brizard ]
 
Srikanth Shenoy
author
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jess,

I agree with what other people have had to say regarding testing Struts app.
The reason is the same: All the business logic gets tested in their respective JUnit methods.
The only tests that I do for my Struts classes is actually launch the browser to do a manual end-to-end testing - that too only when I write/modify that code.

However the reason for this is that the company I work for has QA team that records the regression test scripts using commercially available tools.

In the absence of such regression scripts, I think Struts Test case or equivalent might be needed.


On another note, does anybody know of a open source/free regression test recorders that has the capability of parameterization and assertion (like the commercial tools)?

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jess,
Like the others, I keep the business logic out of the action. I use mock objects (easy mock) to check getting/storing values in the session/request.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since mister Holmes mentioned in another thread that the book covers unit testing Struts applications, I thought it would be beneficial to revive this thread...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic