Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

test my jsp of my web application no in the networc company

 
Dora Di Donato
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
How can test a jsp that use the tag of spring and the controlle exends the simpleformcontroller of my webapplicatio but I am not on the network company so I don't find the databes,webservise and other.
Someone can suggest me there is a way??

thans

D.Donato
 
Tim Cooke
Sheriff
Pie
Posts: 3149
136
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are describing here, including the controllers, application, database, webservices, is not Unit Testing. That sounds very much like an Integration Test to me.

Unit testing the presentation layer is, and always has, been a difficult task. But there are a couple of tools in the kit that we can use.

First off you can use a web testing tool such a Selenium to drive and observe the Browser user interface. These sorts of tools hook into the browser using the xpath, DOM id, or DOM class. The advantage of these sorts of tools is that they're relatively easy to get going with. The downside is that they require a browser to be installed to run and can be quite picky with what browsers and versions they're run with. Another downside is that if you change the UI you may break your tests. This leads your tests to be pretty flakey.

Secondly you can use something like JspTest which will directly test the data being passed up to the presentation layer in the JSP tags. While you are not testing the layout of your UI (which you probably shouldn't be doing anyway) it will test that the required data is being received correctly and for submission data is being sent correctly. You are now testing the functionality of your presentation layer with a Unit Test which is really what we want to be doing. (Disclaimer: I haven't used JspTest, just read about it in Lasse Koskela's Test Driven book).

If you setup your test cases so that the controllers are mocked out then you do not need access to anything beyond that to run your presentation Unit Tests. So lack of network access will not be a problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic