Skip to content

Instantly share code, notes, and snippets.

@tomekw
Created August 29, 2018 12:38
Show Gist options
  • Save tomekw/7596b250cd9adee74b141597a795f974 to your computer and use it in GitHub Desktop.
Save tomekw/7596b250cd9adee74b141597a795f974 to your computer and use it in GitHub Desktop.
// 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