background image
<< Part 3. Testing Enterprise JavaBeans | Requirements for EJB Testing >>
<< Part 3. Testing Enterprise JavaBeans | Requirements for EJB Testing >>

EJB TestScripts

30
Chapter 3 - Testing Enterprise JavaBeans
s
The implementation or bean class implements the business methods defined by the
remote interface.
s
The primary key class provides a pointer into a database. Only entity beans require a
primary key.
Because client applications interact directly with the home and remote interfaces and
not with the implementation class, and because test scripts emulate client
applications, EJB testing needs to test only the methods defined in the remote and
home interfaces.
EJB TestScripts
All test scripts that are generated or constructed manually extend
com.rational.test.tss.TestScript
, an abstract class that contains the code
necessary to connect to a project, initialize log information, and look up the name of
the script.
All EJB test scripts that extend the
TestScript
class must implement a
main
method and a
testMain
method.
s
The
main
method is the entry point for the class.
s
The
testMain
method is the entry point for the testing code.
testMain
includes
all of your test logic. All calls to other test scripts must reside within
testMain
.
In addition, all EJB test scripts must call
tms.startTestServices
and
tms.endTestServices
.
s
tms.startTestServices
initializes logging and other test services and should
be the first method called in
testMain
(within a try block).
s
tms.endTestServices
turns off logging, writes the log file, and performs
various cleanup functions and should be the last method called in
testMain
(in
your
finally
block).
Packages Imported Into EJB Test Scripts
EJB test scripts must also import the following packages:
s
com.rational.test.ct.*
s
com.rational.test.tss.*
s
com.rational.test.vp.*
s
com.rational.test.vp.ui.*
s
java.util.*