Java Reference
In-Depth Information
Figure 15.3
Results from the execution of our JSFUnit tests in a browser
To execute the tests you can use Ant or Maven (see chapter 14), or you can execute
your tests from a browser.
15.5.1
Executing a JSFUnit test from a browser
To execute tests from a browser, place the cactus-report.xsl file that comes with the
Cactus distribution in the root of your web application. After you package the applica-
tion, deploy it to a servlet container and use a URL like the following:
http://localhost:8080/ch15-jfsfunit/ServletTestRunner?suite=com.manning.
junitbook.ch15.beans.TestListAvailableAlbumsBean&xsl=cactus-report.xsl
You'll see the results of the test execution, as shown in figure 15.3.
Now let's talk a little about Ajax.
15.5.2
Testing Ajax using JSFUnit
The Ajax elements of an application are scary for most developers to test. But as you
saw in chapter 13, it isn't that hard to test Ajax. In this section we focus on testing the
Ajax layer of our application, this time using JSFU nit.
Listing 15.11 shows the album_details.jsp page of our MusicStore application,
which will allow us to purchase a given album.
Listing 15.11 album_details.jsp
...
<td>
<rich:panel bodyClass="rich-laguna-panel-no-header">
<a4j:commandButton id="PurchaseButton"
value="Purchase" reRender="rep"
action="#{albumDetailsBean.purchase}">
<a4j:actionparam id="status" name="status"
value="Successfully purchased:
#{albumDetailsBean.album.name}"
assignTo="#{albumDetailsBean.status}"/>
</a4j:commandButton>
<rich:spacer width="20" />
B
C
D
 
 
 
 
 
Search WWH ::




Custom Search