The Artima Developer Community
Sponsored Link

Drive Your Unit Tests with Custom Scripts
How to Customize Suite Execution by Overriding execute
by Bill Venners
March 10, 2003

<<  Page 4 of 11  >>

Advertisement

A Hand-Written Account Test Script

Here's a complete hand-written script that performs basic testing of class Account:

# Test Account's constructor
newAccount
getBalance 0 # Constructor should initialize balance to zero.

# Test Account's deposit method
newAccount
deposit 20
getBalance 20 
deposit 20
getBalance 40 
deposit -1 java.lang.IllegalArgumentException

newAccount
deposit 9223372036854775807 # Deposit Long.MAX_VALUE
getBalance 9223372036854775807 

newAccount
deposit 100
deposit 9223372036854775807 java.lang.ArithmeticException

# Test Account's withdraw method
newAccount
deposit 20
withdraw 10
getBalance 10
withdraw 10
getBalance 0
withdraw 10 com.artima.examples.account.ex6.InsufficientFundsException

newAccount
withdraw -1 java.lang.IllegalArgumentException

<<  Page 4 of 11  >>




Google
  Web Artima.com   
Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us