Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to unit test jsf 2.0 Managed Bean

What is the most effective way of unit testing JSF 2.0 managed beans. I have seen JSFUnit from JBoss but it looks like its for testing the components in the facelets pages but not the managed beans themselves.

I want to find a way to effectively unit test only the managed beans.

Any ideas?

like image 475
Farouk Alhassan Avatar asked Feb 25 '23 20:02

Farouk Alhassan


2 Answers

Set up your managed beans so that all their dependencies are injected as managed properties via setters. Then you can manually inject mocks or stubs in your unit tests.

like image 136
Michael Borgwardt Avatar answered Feb 27 '23 11:02

Michael Borgwardt


JSFUnit is another alternative

like image 26
Aravind Yarram Avatar answered Feb 27 '23 11:02

Aravind Yarram