SampleCalculator() it("should return the result of adding the first number to the second number") { val sum = calculator.sum(2, 4) assertEquals(6, sum) } . . . } })
SampleCalculator() it("should return the result of adding the first number to the second number") { val sum = calculator.sum(2, 4) assertEquals(6, sum) } it("should return the result of subtracting the second number from the first number") { val subtract = calculator.subtract(4, 2) assertEquals(2, subtract) } } })
it("should return the result of adding the first number to the second number") { assertEquals(6, subject.sum(2, 4)) (2) } it("should return the result of subtracting the second number from the first number") { assertEquals(2, subject.subtract(4, 2)) (2) } }) Subjects
case a Calculator. This will be invoked for every test scope, which means each test scope will have a unique instance. (2) Use subject to access the instance of the subject. Subjects
sync. • Studio Plugin isn’t 100% working, can be a bit flaky • Mockito! ◦ Null issues due to Kotlin’s nullability protection ▪ Use Mockito-Kotlin (https://github.com/nhaarman/mockito-kotlin) • Depends on Mockito 2.1.0 ◦ 2.1.0 was just released last month... Caveats