07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

514 Zhen Ru Dai<br />

BluetoothUnitTest<br />

<br />

SlaveRoam<strong>in</strong>gListTest<br />

<br />

testSearchNextElement(): Verdict<br />

testIsNull(): Verdict<br />

sd testSearchNextElement():Verdict<br />

<br />

SlaveRoam<strong>in</strong>gListTest<br />

return pass<br />

SlaveRoam<strong>in</strong>gList<br />

(["M1","M2","M3"])<br />

searchNextElement(−):"M1"<br />

<br />

(a) Test Package<br />

searchNextElement()<br />

RList:<br />

SlaveRoam<strong>in</strong>gList<br />

SlaveRoam<strong>in</strong>gList([])<br />

(b) Test Scenario<br />

BluetoothRoam<strong>in</strong>g<br />

emptyList:<br />

SlaveRoam<strong>in</strong>gList<br />

Fig. 17.13. JUnit Test Package and Scenario<br />

Mapp<strong>in</strong>g to JUnit In the <strong>in</strong>troduced roam<strong>in</strong>g algorithm, the handl<strong>in</strong>g of the<br />

slave roam<strong>in</strong>g list plays an important role <strong>in</strong> order to guarantee the right choice<br />

of the successory master. Therefore, class SlaveRoam<strong>in</strong>gList will be tested. This<br />

class provides the follow<strong>in</strong>g methods:<br />

• boolean isNull(): checks if the roam<strong>in</strong>g list is empty. True, if the list is empty,<br />

otherwise false.<br />

• Str<strong>in</strong>g searchNextElement(): looks for the next element <strong>in</strong> the roam<strong>in</strong>g list.<br />

Method isNull() asks whether or not is the roam<strong>in</strong>g list empty, so that no<br />

alternative new master can be found. In case of be<strong>in</strong>g empty, warn<strong>in</strong>gs will be<br />

sent to the environment. Method searchNextElement() gives out the name of the<br />

new master.<br />

Figure 17.13 shows the unit test specification with U2TP. Figure 17.13a)<br />

depicts a test package called BluetoothUnitTest. The package imports from the<br />

implementation package of the package BluetoothRoam<strong>in</strong>g, <strong>in</strong> which the methods<br />

isNull() and searchNextElement() are specified. The test context <strong>in</strong> the test package<br />

is called SlaveRoam<strong>in</strong>gListTest, which <strong>in</strong>cludes two test cases: testSearchNextElement()<br />

and testIsNull(). The names of the tests are similar to the methods which<br />

should be tested. They just beg<strong>in</strong> with the prefix ”test” for a better recognition.

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

Saved successfully!

Ooh no, something went wrong!