In this podcast, JSFCentral editor-in-chief Kito D. Mann talks with Stan Silvert about JSFUnit, an open source integration testing and debugging framework for JSF applications and JSF AJAX components. This interview was recorded in September of 2008 at JSFOne.
Here is an excerpt:
Kito: So let’s say I am writing my JSF application and I decide I want to get JSFUnit and I download it. What do I have to do? Let’s say I want to test…like a login page and I have written my backing bean and have some components on the page and I want to test that it works OK.
Stan: What you do is get the JSFUnit JAR, of course with several supporting JARs. There is a “getting started” page -- if you go to jsfunit.org you can see all this step by step. You get the JARs, you do make some modifications to your web XML to set up a couple of filters and a couple of extra filters that are used by Cactus, which is what we use to do the in-container magic for JUnit. Then you write your test, which is usually very few lines of code. You have a JSF client session and a JSF server session so you use the JSF client session to click things on the page and you input things on the form and such as that. Then every time there is an HTTP request you can go to this JSF server session object and look at all the things on the server, like the value of your managed beans. Did the value really make it into the managed bean like you expected? Did the component tree turn out the way you expected? It is a very powerful way to do assertions instead of having to do assertions on the HTML – which is something we still allow you to do – but really a better way is to assert that the JSF component tree turned out right. Because that is what your logic actually took care of. Like I say, it’s not many lines of code to write tests to test things.
Read the full article or download the podcast here: http://www.jsfcentral.com/articles/silvert-08-09.html
Kito D. Mann -- Author, JavaServer Faces in Action
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
+1 203-404-4848 x3