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.

think about estimating<br />

Even<br />

though you<br />

don’t know<br />

exactly<br />

how this<br />

code works,<br />

it should<br />

be clear<br />

what it<br />

should do.<br />

package test.com.orionsorbits.mercurymeals;<br />

import com.orionsorbits.mercurymeals.*;<br />

import org.junit.*;<br />

public class TestMercuryMeals {<br />

String[] options;<br />

String flightNo;<br />

}<br />

@Before<br />

public void setUp() {<br />

options = {"Fish and chips");<br />

flightNo = "VS01";<br />

}<br />

@After<br />

public void tearDown() {<br />

options = null;<br />

flightNo = null;<br />

}<br />

@Test<br />

public void testOrderRegularMeal()<br />

throws MealOptionNotFoundException, OrderNotAcceptedException {<br />

}<br />

MercuryMeals mercuryMeals = MercuryMeals.getInstance();<br />

Order order = mercuryMeals.createOrder();<br />

MealOption mealOption = mercuryMeals.getMealOption(options[0]);<br />

if (mealOption != null) {<br />

order.addMealOption(mealOption);<br />

} else {<br />

throw new MealOptionNotFoundException(mealOption);<br />

}<br />

order.addKeyword(flightNo);<br />

if (!mercuryMeals.submitOrder(order)) {<br />

throw new OrderNotAcceptedException(order);<br />

}<br />

398 Chapter 11<br />

Your job was to create a unit test that exercises all <strong>of</strong> the functionality your<br />

user stories need. The “Order Regular Meal” test creates an order, adds a<br />

regular meal option to it (in this case, “Fish and chips”), and then submits<br />

the order to Mercury Meals.<br />

These exceptions are just ways<br />

to cause the test to fail, and<br />

say something in the Mercury<br />

Meals API didn’t work.<br />

Download at WoweBook.Com<br />

Title:<br />

Est:<br />

Priority:<br />

Here’s the user<br />

story you’re testing<br />

Mercury Meals<br />

functionality for.<br />

Order Regular Meal<br />

12 days<br />

10<br />

Create an order and<br />

get the single meal<br />

option that was set<br />

up prior to the test<br />

being run.<br />

Add the “Fish and chips” meal<br />

option to the order, tie the<br />

order to the flight number,<br />

and then submit the order to<br />

Mercury Meals.

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

Saved successfully!

Ooh no, something went wrong!