tdd-java-demo
tdd java demo with micro-commits
git clone https://9o.is/git/tdd-java-demo.git
commit d145cf07371036d38cbbbe0062e5fb1d385e2200 parent 58f55bfbd857b3d2af8ea19b7a92413cc99b74a7 Author: Jul <jul@9o.is> Date: Wed, 31 Mar 2021 17:10:06 +0800 add milk and apple items Diffstat:
| M | src/main/java/takehome/Runner.java | | | 4 | +++- |
| M | src/test/java/takehome/RunnerTest.java | | | 6 | ++++-- |
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/main/java/takehome/Runner.java b/src/main/java/takehome/Runner.java @@ -20,7 +20,9 @@ public class Runner { public void run() { Item[] items = { new Item("soup", 0.65), - new Item("bread", 0.80) + new Item("bread", 0.80), + new Item("milk", 1.30), + new Item("apple", 0.10) }; Map<Item, Integer> amounts = getItemAmounts(items); diff --git a/src/test/java/takehome/RunnerTest.java b/src/test/java/takehome/RunnerTest.java @@ -17,12 +17,14 @@ class RunnerTest { assertThat(output(), contains( "How much soup? ", "How much bread? ", - "Total: $1.45" + "How much milk? ", + "How much apple? ", + "Total: $2.85" )); } private List<String> output() { - ByteArrayInputStream in = new ByteArrayInputStream("1\r1".getBytes()); + ByteArrayInputStream in = new ByteArrayInputStream("1\r1\r1\r1".getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); new Runner(in, out).run(); return Arrays.asList(out.toString().split("\n"));