-
1. Re: Testable Components
ssilvert Jan 17, 2008 8:05 AM (in response to kingkon)Theoretically, JSFUnit can test any JSF component. Out of the box, JSFUnit can be used with any component that does not use Ajax/javascript to do a submit. For RichFaces, we have special code for testing applications using those particular RichFaces components. So JSFUnit does work with most components of the RichFaces component library. The tree control is the one notable exception. This open jira task tracks the completion of RichFaces support.
http://jira.jboss.com/jira/browse/JSFUNIT-48
It is possible to create your own handler for other libraries. Our goal is to eventually support all the major JSF/Ajax component libraries out there. See this page for more details:
http://wiki.jboss.org/wiki/AjaxWithJSFUnit
If you go to our JSFUnit/RichFaces demo, you can see how to use JSFUnit to test each supported component. There will be a "View JSFUnit Source" link that shows source code for testing each component.
See http://labs.jboss.com/jsfunit/demo.html
Stan -
2. Re: Testable Components
kingkon Jan 17, 2008 9:01 AM (in response to kingkon)Thanks Stan.....
but can we test combo box like we have methods in JSFClientSession to test checkbox.... like we have setCheckbox(....)..but i don't find any methods for combo box r radiobutton r something else....can u suggest some idea regarding this.. -
3. Re: Testable Components
ssilvert Jan 17, 2008 9:24 AM (in response to kingkon)Combo Boxes and Radio Buttons can be set with the JSFClientSession.setParameter() method.
There is an example of setting a value of a radio button in the RichFaces demo calendar test:
http://jsfunit.demo.jboss.com/jboss-jsfunit-examples-richfaces/richfaces/calendar.jsf?c=calendar
Click on the "View JSFUnit Source" and look for the line of code that says, "client.setParameter("form1:Locale", "de/DE");"
Regards,
Stan -
4. Re: Testable Components
fhomasp Aug 21, 2008 3:39 AM (in response to kingkon)Hey,
Perhaps I should make another thread for this, I'm open for suggestion :)
I have a question about checkboxes. I've seen an example here for Ajax checkboxes. However it's not really using the client.setCheckBox(String,boolean) method. This one also has me somewhat puzzled. All html ID's for checkboxes (selectManyCheckbox) are the same for every checkbox in the same definition, how does one test them individually?
client.setCheckbox("id",boolean) doesn't address them like that. Or am I missing something?<h:selectManyCheckbox id="instanties" value="#{A001BeanD.vakDData.instantie}" layout="pageDirection" styleClass = "noBorder"> <f:selectItems value="#{A001BeanD.vakDData.instantieList}" id="instantielijst"/> </h:selectManyCheckbox>
<tr><td><table class="noBorder" id="_id22:instanties"> <tr><td><label><input type="checkbox" name="_id22:instanties" value="R.V.A." class="noBorder" /> R.V.A.</label></td></tr>
<tr><td><label><input type="checkbox" name="_id22:instanties" value="Ziekenfonds" class="noBorder" />  Ziekenfonds</label></td></tr>
-
5. Re: Testable Components
fhomasp Aug 21, 2008 8:02 AM (in response to kingkon)client.setParameter("_id22:instanties","R.V.A.");
This seems to work. I have yet to check after submit if the value is there on the server. I also can't uncheck using this method.
However, every time I attempt to write something to a tomahawk <t:selectOneRadio> I get a nullpointer exception returned. -
6. Re: Testable Components
ssilvert Aug 21, 2008 8:04 AM (in response to kingkon)A new thread would have been better, but that's OK.
This is something we haven't addressed yet. If you used <f:selectItem> instead of <f:selectItems> you would have unique id's. But of course, you can't always hard code your items.
I don't see how to set this in HttpUnit, but I bet if you search their mail lists you will find a solution.
In just a few days, I'll be releasing JSFUnit Beta 3. This relies on HtmlUnit instead of HttpUnit. We still won't have a JSFUnit API solution, but you will be able to easily manipulate the DOM to do whatever you want.
I've opened a new jira task to create the JSFUnit API solution before GA:
https://jira.jboss.org/jira/browse/JSFUNIT-156
Stan -
7. Re: Testable Components
fhomasp Aug 21, 2008 9:45 AM (in response to kingkon)Thanks for the answer, and the Jira task. You guys mean business eh :)
It seems that when I set a value to a combobutton I always get a nullpointerexception thrown at me. If i try a numeric value I get a message telling me to set a value I just tried.
And attempting to set more than one value to a selectmany item enables only the value which was set the last.
Checking the ArrayList behind the JSF bean after submitting always returns an ArrayList of one item, namely the last one set.client.setParameter("_id22:instanties","R.V.A."); client.setParameter("_id22:instanties","Ministerie van Sociale Voorzorg"); client.setParameter("_id22:instanties","Ziekenfonds"); client.setParameter("_id22:instanties","Fonds voor beroepsziekten"); client.setParameter("_id22:instanties","Fonds voor arbeidsongevallen"); client.setParameter("_id22:instanties","Verzekeringsmaatschappij"); client.setParameter("_id22:instanties","Administratie Ruimtelijke Ordening en Huisvesting"); client.setParameter("_id22:instanties","Kinderbijslagkas (bijkomende kinderbijslag)"); client.setParameter("_id22:instanties","andere:");
So the ArrayList behind the instances variable contains on value, namely: "andere:". Which appears to be making a selectOneXXX from a selectManyXXX. Or that's what I make of it, I'm fairly new to all this :)