Index: core-module/pom.xml =================================================================== diff -u -rc41ae0ad9e7fe3b7781abd7686d5a1cbf2a4be3c -re3041de1aa7ca084d9be5b77ec03656b930fed71 --- core-module/pom.xml (.../pom.xml) (revision c41ae0ad9e7fe3b7781abd7686d5a1cbf2a4be3c) +++ core-module/pom.xml (.../pom.xml) (revision e3041de1aa7ca084d9be5b77ec03656b930fed71) @@ -46,6 +46,12 @@ scala-library 2.12.6 + + org.scalatest + scalatest + 1.2 + test + Index: core-module/src/test/scala/tutorial/Pizza.scala =================================================================== diff -u --- core-module/src/test/scala/tutorial/Pizza.scala (revision 0) +++ core-module/src/test/scala/tutorial/Pizza.scala (revision e3041de1aa7ca084d9be5b77ec03656b930fed71) @@ -0,0 +1,15 @@ +package tutorial + +import scala.collection.mutable.ArrayBuffer + +case class Topping(name: String) + +class Pizza { + + private var toppings = new ArrayBuffer[Topping] + + def addTopping (t: Topping) { toppings += t} + def removeTopping (t: Topping) { toppings -= t} + def getToppings = toppings.toList + +} \ No newline at end of file Index: core-module/src/test/scala/tutorial/PizzaTests.scala =================================================================== diff -u --- core-module/src/test/scala/tutorial/PizzaTests.scala (revision 0) +++ core-module/src/test/scala/tutorial/PizzaTests.scala (revision e3041de1aa7ca084d9be5b77ec03656b930fed71) @@ -0,0 +1,26 @@ +package tutorial + +import org.junit.Test +import junit.framework.TestCase +import org.junit.Assert._ + +class PizzaTests extends TestCase { + + var pizza: Pizza = _ + + override def setUp { + pizza = new Pizza + } + + def testOneTopping { + pizza.addTopping(Topping("green olives")) + assertEquals(pizza.getToppings.size, 1) + } + + def testAddingAndRemovingToppings { + pizza.addTopping(Topping("green olives")) + pizza.removeTopping(Topping("green olives")) + assertEquals(pizza.getToppings.size, 0) + } + +} \ No newline at end of file