February 2015
Intermediate to advanced
338 pages
8h 16m
English
For the sake of simplicity, let’s use the second simplest data store after memory—a file. Let’s get our step definition to write out the fruit information to a file:
| rest_web_services/02/src/test/java/fruit/FruitSteps.java | |
| Line 1 | package fruit; |
| - | |
| - | import com.google.gson.Gson; |
| - | |
| 5 | import cucumber.api.java.en.*; |
| - | |
| - | import java.io.PrintWriter; |
| - | import java.util.List; |
| - | |
| 10 | public class FruitSteps { |
| - | @Given("^the system knows about the following fruit:$") |
| - | public void theSystemKnowsAboutTheFollowingFruit(List<Fruit> fruitList) |
| - | throws Throwable { |
| - | Gson gson = new Gson(); |
| 15 | PrintWriter writer = new PrintWriter("fruit.json", "UTF-8"); |
| - | writer.println(gson.toJson(fruitList)); ... |
Read now
Unlock full access