background image
<< Message Signature Examples | Sample Application >>
<< Message Signature Examples | Sample Application >>

Stubs

18
Chapter 2 - Basic Concepts
Example 3 Name and Type
This example shows the message signature when you display name and type without
including parameter values or assignment statements.
getBalance(acctountID : long, acctType : java.lang.String, amount :
double)
Example 4 Name and Type with Parameter Values
This example shows the message signature after you add the initial data assigned to
each parameter.
getBalance(accountID : long = 1, acctType : java.lang.String =
"checking", amount : double = 50)
Example 5 Name and Type with Assignment Statement
Finally, if the message returns a value and you want to establish a variable in the test
script to hold this value, possibly for use as a parameter of data in a subsequent
message, you need to convert the message name into an assignment statement. In this
example, the variable named
result
is declared and used in the test script to hold
the value returned by the
getBalance()
function.
result = getBalance(accountID : long = 1, acctType : java.lang.String =
"checking", amount : double = 50)
Stubs
Stubs are components that can be used for testing purposes in place of actual
components. A stub can be either a pure "dummy" component that just returns some
predefined value, or it can simulate more complex behavior. With QualityArchitect,
the simulated behavior for stubbed operations is specified in a lookup table. Through
the use of stubs, you can control the results returned from components that interact
with the component-under-test and create a simulated, controlled test environment.
Consider the sample EJB application that is described in the chapter on Testing
Enterprise JavaBeans
. In this chapter, you create a test script to test the
getBalance
method that is included with the
ExecuteTransaction
interface. Because the
getBalance
method calls several methods in the
ManageAccount
EJB, such as
getSavingsBalance
and
getSavingsCustomerID
, you would need to control
access to the
ManageAccount
EJB to thoroughly test the
getBalance
method. As an
alternative, you can create a stub for the
ManageAccount
EJB and control the results
returned when
getBalance
calls the methods in the
ManageAccount
EJB.