Junitee
Translation: slovenboy
Email: Slovenboy at Yahoo Dot CoM Dot CN
BLOG:
http://slovenboy.blogdriver.com
Resembling and publishing: Please keep the translator information and contact me
TUTORALIAL
This guide will explain how to use Junitee to do unit testing of EJB.
All source code in Junitee's distribution (Distribution)
Of the example directory, you can also online (
http://www.junitee.org/tutorial/index.html) Browse.
Implement EJB
The EJB used in this guide is a simple session bean for two digits. Check
Org.junitee.eb.einstein Source Codes in Packages Learn about the working mechanism in Beans.
The AddTwonumBers method has a small error to illustrate the effect of test failed, the method EMC2 is only
Throw an exception to cause test errors.
Write test case
The test case is a standard JUnit Test case (TESTCASE). For FixTure, you
You can use the default JNDI InitialContext to get the EJB reference, as follows:
Protected void setup () throws exception {context jndicontext = new initialContext ();
Object einRef = JNDICONTEXT.LOOKUP ("java: comp / eNV / EJB / Einsteinejb"); EinsteinHome Home = (EinsteinHome) PortableRemoteObject.Narrow (EinRef, EinsteinHome.Class);
THIS.EIN = home.create ();
Test method is like this:
Public void testsimpleaddition () THROWS RemoteException {string result = this.ein.addtwonumbers ("7", "10"); assert (Result.equals);}
The full code of the test case is included in the example - view the org.junitee.ejb.einstein.test package.
Create a front-end web form
The JUNITESERVLET performs the test case specified by the "Suite" form parameter, which can appear.
Use a simple form to start testing:
You May Type in the name of a test suite: