Created
August 29, 2018 12:38
-
-
Save tomekw/7596b250cd9adee74b141597a795f974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: src/test/kotlin/com/_98elements/CalculatorSpec.kt | |
package com._98elements | |
import org.junit.jupiter.api.Assertions.assertEquals | |
import org.junit.jupiter.api.assertThrows | |
import org.spekframework.spek2.Spek | |
import org.spekframework.spek2.style.specification.describe | |
object CalculatorSpec: Spek({ | |
describe("adding numbers") { | |
it("adds 2 to 2") { | |
assertEquals(4, Calculator.add(2, 2)) | |
} | |
} | |
describe("dividing numbers") { | |
it("divides 4 by 2") { | |
assertEquals(2, Calculator.divide(4, 2)) | |
} | |
context("when dividing by 0") { | |
it("throws ArithmeticException") { | |
assertThrows<ArithmeticException> { Calculator.divide(2, 0) } | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment