This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Testing and the fly likes How can I ensure my whole stack is tested automatically? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Testing
Reply Bookmark "How can I ensure my whole stack is tested automatically?" Watch "How can I ensure my whole stack is tested automatically?" New topic
Author

How can I ensure my whole stack is tested automatically?

James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Hi,

I've got a stripes/spring/jpa/jsp/hibernate/mysql stack web application. I'm looking to implement some sort of automated testing, but I'm really unsure of how to approach this.

I've had a look at JUnit as that seemed the natural choice, but how can I run tests on such simple code as below?




For example, one of my JSPs looks like this, is there anyway I can test to make sure the variables are correct? Say I rename some attributes on my domain class, I'd like a test to fail if I forget to go through my JSPs and rename attributes



Should I not be as concerned about testing? Testing is good practice, and so far I haven't done any, I really want to change this but could do with some advice

thanks


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The two things would (necessarily) be tested completely differently. If you want to test the output of a JSP you really want to do integration testing, driving a browser, and so on. Testing the first method can really depend: do you want to test your full JPA stack (also integration testing), or do you want to test what persistClient itself is doing, which is do one behavior if there's no ID, or a different one if there is?
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

I think the problem that I have, is that I'm not sure on what I should be testing

At the moment my application is a simple CRUD application, and I can't find anywhere that would be suitable for automated testing. For example there is no need for me to test .persist()

Maybe I should only be testing my action and service layers?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

James Elsey wrote:For example there is no need for me to test .persist()

Of course not--you didn't write it.
Maybe I should only be testing my action and service layers?

You should only be testing your own functionality--not that of your persistence or application framework, which should already be tested.

How deep to take that testing depends--in your example above, you're just testing ID v. no ID behavior.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How can I ensure my whole stack is tested automatically?
 
Similar Threads
Struts 2 checkboxlist error - list key could not be resolved
Hyperlink not calling the method
Can not Populate the form on combo box change
Struts 2.1 javascript field validate
Visualizing Struts Froms