Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris

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

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??


Posts: 4725
IntelliJ IDE Python Java Linux
  • 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.
I think I'll just lie down here for a second. And ponder this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!