Calling the Code to be Tested


Finally, the next four nonblank lines are the definition of login. This login is a bridge to the login code we're going to test, part of the XTrack system. Our login method just calls that code and passes its id and password parameters on. Creating the login method required knowledge of how the XTrack code is written, because we're calling that code just the way the other parts of the XTrack system do. This is where pairing with the programmers on your team comes in handy.

Since we're the programmers on your team right now, we'll explain how this code works in the XTrack system. Your mileage may vary; the login code you'd be calling on your own application under test might not work this way at all, and you (or whoever creates your XTrackTest equivalent) will have to know how your login code works to write this method for your system.

The login code in XTrack is a method of a class named XTrackSession. The XTrackSession class is used throughout the XTrack system to keep track of user sessions. When a user attempts to log in, the system calls the login method of an XtrackSession object with the id and password the user typed in. Luckily, the login method of XTrackSession has exactly the parameters we want in our login id and password and returns true if the login attempt succeeds and false if it fails.

Consequently, our login creates an XTrackSession, then calls its login method, passing the same id and password parameters that were passed to it. Our login then returns whatever value the session login method returns.



Testing Extreme Programming
Testing Extreme Programming
ISBN: 0321113551
EAN: 2147483647
Year: 2005
Pages: 238

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net