Chapter 22. Making Executable Tests Run


As we mentioned previously, the executable tests we've written can be run as soon as the corresponding code has been completed, if we can call those parts of the system (like the login code) directly from the tests. In this chapter, we're going to illustrate this with a simple example. We're going to use JUnit (www.junit.org) as our test framework. JUnit will provide a lot of the infrastructure we need, including a way to run the test and get graphical test results.

If you're using some other framework or test tool, no problem. You'll apply the same principles we show to your own executable tests, using the appropriate language and framework. Nearly every language has JUnit equivalents (collectively referred to as XUnit), which you can find at www.xprogramming.com/software.htm.

If you're worried your programming skills aren't up to this or are concerned because you don't have an intimate knowledge of the application code you're testing, remember that you'll be able to pair with the programmers on your team to create these tests. At the very least, you can write up the tests as we showed in Chapter 16, and the programmers can take it from there. Check out Chapter 23 for more help if this is your situation. Once you walk (or climb) through our examples and exercises with us, you may feel more confident.

Suppose the XTrack system is written in Java and we've written the tests for the login function as follows:

 public class LoginStoryTest {     public void testLogin() {        assertTrue( login("bob","bobspassword") );       assertTrue( login("BOB","bobspassword") );       assertFalse(login("bob",""));       assertFalse(login("bob","BOBSPASSWORD") );    } } 


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