Lab #8 (Server-less Testing with TestNG)
Overview
Seam provides full round-trip testing capabilities without the need
to deploy to a server. Using TestNG, a JUnit alternative that's JUnit
compatible, you will test a Seam application.
Lab Instructions
- Open your seam command window/shell
- type: cd @seamHome@
- type: seam switch-project (helloworld-lab8 should be entered as the project name)
- CHEAT:
- type: seam labs-cheat (Enter '8' for the lab cheat you want to apply)
-
NO CHEAT:
-
Create a new SLSB Action, Facelet and TestNG Test Case
-
Open Seam Command Window:
-
type:
cd @seamHome@
-
type:
seam new-action (This will create a new SLSB, facelet
(for visual testing), and TestNG Test Case (for server-less
testing)
-
type:
cd @seamHome@
-
type:
seam explode restart
-
Goto URL:
http://localhost:8080/helloworld-lab8/hello.seam
- type: seam unexplode (Will undeploy the exploded EAR file)
-
EXTRA CREDIT: Implement a new method/test case that always throws
a NullPointerException.
-
Edit
HelloBean.java and Hello.java
-
Create a new method called
badGreeting()
-
Throw a NullPointerException in badGreeting()
-
Edit
HelloTest.java
-
Create a new test method called
badGreetingTest() that invokes
HelloBean.badGreeting()
-
Open Seam Command Window
-
type:
cd @seamHome@
-
type:
seam test(This will run the TestNG test suite)
-
Goto URL:
@workspaceHome@@sep@helloworld-lab8@sep@testng-report@sep@index.html
Key Files
@workspaceHome@@sep@helloworld-lab8@sep@resources@sep@WEB-INF@sep@components.xml
@workspaceHome@@sep@helloworld-lab8@sep@resources@sep@WEB-INF@sep@faces-config.xml
@workspaceHome@@sep@helloworld-lab6@sep@resources@sep@WEB-INF@sep@web.xml
@workspaceHome@@sep@helloworld-lab8@sep@src@sep@com@sep@mydomain@sep@helloworld@sep@Hello.java
@workspaceHome@@sep@helloworld-lab8@sep@src@sep@com@sep@mydomain@sep@helloworld@sep@HelloBean.java
@workspaceHome@@sep@helloworld-lab8@sep@src@sep@com@sep@mydomain@sep@helloworld@sep@test@sep@HelloTest.java
@workspaceHome@@sep@helloworld-lab8@sep@src@sep@com@sep@mydomain@sep@helloworld@sep@test@sep@HelloTest.xml
@workspaceHome@@sep@helloworld-lab8@sep@view@sep@hello.xhtml
Home |
Next