Skip to content

Instantly share code, notes, and snippets.

@koljamaier
Created June 29, 2018 22:04
Show Gist options
  • Save koljamaier/c43d4b19034940c1e9784bf83c65155d to your computer and use it in GitHub Desktop.
Save koljamaier/c43d4b19034940c1e9784bf83c65155d to your computer and use it in GitHub Desktop.
This is a simple Test suite for scala unit testing
package nqueens
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class NqueensTest extends FunSuite {
// test("string take") {
// val message = "hello, world"
// assert(message.take(5) == "hello")
// }
trait TestSet {
val queens = List(0,3,1)
}
test("adding ints") {
assert(1 + 2 === 3) // z.B: so assert(1 + 4 === 3)
}
test("testIsValid") {
assert(Nqueens.isValid(col = 2,n = 4, partialSolution = List(2,2,2)) == false)
}
test("testIsSafe") {
new TestSet {
assert(Nqueens.isSafe(col = 2, queens))
assert(Nqueens.isSafe(col = 2, queens) === true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment