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

Create successful ePaper yourself

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

All <strong>of</strong> this...testing for<br />

functionality, edge cases,<br />

and hokey implementations,<br />

adds up to a complete<br />

testing approach.<br />

Are you kidding me? Did you look at that code we<br />

just wrote? We never once look at the expiration<br />

date on a gift card, and we always set the balance<br />

to 0. How can you call this better code?<br />

Your code may be incomplete, but<br />

it’s still in better shape.<br />

Remember the second rule <strong>of</strong> test-driven development?<br />

Rule #2: Implement the<br />

SIMPLEST CODE POSSIBLE<br />

to make your tests pass.<br />

Even though not everything works, the code that we do have works,<br />

is testable, and is slim and uncluttered. However, it’s pretty clear<br />

that we still have lots <strong>of</strong> work left. The goal is getting everything else<br />

working and keeping any additional code just as high-quality as what<br />

you’ve got so far.<br />

So once you get your basic tests, start thinking about what else you<br />

need to test...which will motivate the next piece <strong>of</strong> functionality to<br />

write code for. Sometimes it’s obvious what to test next, like adding a<br />

test to deal with gift card balances. Other times, the user story might<br />

detail additional functionality to work on. And once all that’s done,<br />

think about things like testing for boundary conditions, passing in<br />

invalid values, scalability tests, etc.<br />

test-driven development<br />

We’ve implemented the basic success-case test for processing<br />

an order, but there are clearly problems with our implementation.<br />

Write another test that finds one <strong>of</strong> those problems, and then write<br />

code to get the test to pass.<br />

Download at WoweBook.Com<br />

you are here 4 301

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

Saved successfully!

Ooh no, something went wrong!