Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • 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
Ranch Hand
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
Ranch Hand
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
Ranch Hand
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
Ranch Hand
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!