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.

green means pass<br />

Get your tests to GREEN<br />

The only goal you should have at this point is to get your test<br />

to pass. So write just the code you have to in order for your test to<br />

pass; that’s called getting your tests to green.<br />

public class OrderInformation {<br />

} OrderInformation<br />

Yes, that’s it. An empty class. Now try running your test again:<br />

File Edit Window Help Classy<br />

hfsd> javac -d bin -cp junit.jar *.java<br />

hfsd> java -cp junit.jar;.\bin org.junit.runner.<br />

JUnitCore headfirst.sd.chapter8.TestOrderInformation<br />

JUnit version 4.4<br />

.<br />

Time: 0.018<br />

OK (1 test)<br />

hfsd><br />

280 Chapter 8<br />

SUCCESS!<br />

With this test passing, you’re ready to write the next test, still<br />

focusing on your first task. That’s it—you’ve just made it through<br />

your first round <strong>of</strong> test-driven development. Remember, the goal<br />

was to write just the code you needed to get that test to pass.<br />

Rule #2: Implement the<br />

SIMPLEST CODE POSSIBLE<br />

to make your tests pass.<br />

Download at WoweBook.Com<br />

Green refers to the green bar that<br />

JUnit’s GUI displays when all tests pass.<br />

If any test failed, it displays a red bar.<br />

Here’s the UML for the new<br />

class. No attributes, no methods—<br />

just an empty class.<br />

The test compiles<br />

now, as does the<br />

OrderInformation class.

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

Saved successfully!

Ooh no, something went wrong!