Created
August 30, 2011 18:57
-
-
Save schauder/1181705 to your computer and use it in GitHub Desktop.
A simple collection of ScalaTest examples
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
package de.schauderhaft.testen | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.FunSuite | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import org.scalatest.BeforeAndAfterEach | |
@RunWith(classOf[JUnitRunner]) | |
class DemonstrationTest extends FunSuite with ShouldMatchers { | |
def setup = ("einen Wert", 23) | |
test("Dies ist ein Test der Demonstrieren soll, wie ein ScalaTest test funktioniert") { | |
23 should be > (12) | |
} | |
test("die Klasse unter test muss dies können") { | |
val l = List(12, 23, 45) | |
l should not be ('empty) | |
} | |
test("that this piece throws an exception") { | |
(intercept[IllegalArgumentException] { | |
throw new IllegalArgumentException("wrong") | |
}).getMessage() should include("on") | |
} | |
test("test mit setup") { | |
val (text, length) = setup | |
text.length should be <= length | |
} | |
val testValues = List(("word", 4), ("otherword", 9)) | |
for ((in, l) <- testValues) { | |
test("%s hat Länge %d".format(in, l)) { | |
in should have length (l) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment