01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

testing functionality<br />

BeatB<br />

These stories<br />

have to work in<br />

the demo—you<br />

have to test for<br />

this functionality.<br />

Remember that<br />

Bob overwrote<br />

the code to<br />

handle the<br />

POKE_START_<br />

SEQUENCE<br />

command.<br />

244 Chapter 7<br />

Below is the block <strong>of</strong> code that Bob built for the BeatBox Pro demo (the one that failed<br />

spectacularly), and the two user stories that version <strong>of</strong> the s<strong>of</strong>tware was focused on. On the<br />

next page are three tests that need to pass. How would you test these in code?<br />

public class RemoteReader implements Runnable {<br />

boolean[] checkboxState = null;<br />

String nameToShow = null;<br />

Object obj = null;<br />

public void run() {<br />

try {<br />

while ((obj = in.readObject()) != null) {<br />

System.out.println(“got an object from server”);<br />

System.out.println(obj.getClass());<br />

String nameToShow = (String) obj;<br />

checkboxState = (boolean[]) in.readObject();<br />

if (nameToShow.equals(PICTURE_START_SEQUENCE)) {<br />

receiveJPEG();<br />

}<br />

else {<br />

otherSeqsMap.put(nameToShow, checkboxState);<br />

listVector.add(nameToShow);<br />

incomingList.setListData(listVector);<br />

// now reset the sequence to be this<br />

}<br />

} // close while<br />

} catch (Exception ex) {<br />

ex.printStackTrace();<br />

}<br />

} // close run<br />

}<br />

Download at WoweBook.Com<br />

How could you<br />

test this code<br />

to make sure it<br />

works, even if<br />

another problem<br />

comes up?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!