HTML and CSS Reference
In-Depth Information
<h:panelGroup id="output-message" rendered="#{not empty}">
Hello #{}
The result of the CDI bean and the Facelet page can be seen in Figure 11-5 .
Figure 11-5. The Hello You application
We are now ready to test the application. Our test will be annotated with @RunWith to tell JUnit that we will use
Arquillian as our test runner. We also use the @RunAsClient annotation to tell Arquillian that we will not be testing on
the server side, but rather we will send a request as a web client. This is required for functional testing with the Drone
extension. Next, we will specify the resources and classes that we want to test. This is done by creating a WebArchive
object using the ShrinkWrap API. The WebArchive should contain all the resource and classes and only those. The
purpose is to isolate the files being tested and to avoid adding unnecessary complexity. The method creating the
WebArchive must be annotated @Deployment for Arquillian to detect what must be deployed before executing tests.
Lastly we will write the actual tests. The complete test can be seen in Listing 11-14.
Listing 11-14. Arquillian Test Case for Testing the Hello You Application
package com.apress.projsf2html5.chapter11;
import com.apress.projsf2html5.chapter11.jsf.HelloYou;
import com.thoughtworks.selenium.DefaultSelenium;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
public class HelloYouTest {
Search WWH ::

Custom Search