• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Unit Testability ---JSF  RSS feed

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSF can Components be tested independently as pure java objects?



Thanks
 
Author
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can test JSF components, but you'd have to mock a fair bit of the JSF implementation. The JSF Reference Implementation does that for internal testing.
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by David Geary:
but you'd have to mock a fair bit of the JSF implementation. The JSF Reference Implementation does that for internal testing.



David just one question: Has the RI released it as a public api, i mean the mocks that they use internally?
thanks
 
David Geary
Author
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API for the mocks is not part of the spec. But the JSF 1.1_01 reference implementation is open source, so I believe you can get the source to the mocks if you want.
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just curious, why would you want to Unit Test JSF UIComponents?
 
David Geary
Author
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to unit test components for the same reason you unit test model beans: to make sure they're implemented according to their implicit design decisions and to make sure you don't inadvertently violate those decisions in the future.
 
author
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I use to unit-test my managed beans:

BasePageTestCase:

https://appfuse.dev.java.net/nonav/source/browse/*checkout*/appfuse/extras/jsf/test/web/org/appfuse/webapp/action/BasePageTestCase.java?rev=HEAD

Simple testing of a bean - notice the getManagedBean() call in the setUp() method:

https://appfuse.dev.java.net/nonav/source/browse/*checkout*/appfuse/extras/jsf/test/web/org/appfuse/webapp/action/PasswordHintTest.java?rev=HEAD&content-type=text/plain
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!