diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-02-23 00:55:37 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-02-23 00:55:48 -0600 |
commit | eb12ad14a07cecca59c7990d09055ea6ae59f414 (patch) | |
tree | 5530ecaea14217446c8f782f8dfd3fa35ded4e1d /src/test/scala/org/perl8/test/tap/TestBuilderTest.scala | |
parent | e5ba3c840b3f4654bc354f916d26fcf7ce80a638 (diff) | |
download | scala-test-more-eb12ad14a07cecca59c7990d09055ea6ae59f414.tar.gz scala-test-more-eb12ad14a07cecca59c7990d09055ea6ae59f414.zip |
convert the test suite to use TestMore
still has issues (the tests run in parallel, which messes up the test
output, and the outputstream parameter is required), but it's a start
Diffstat (limited to 'src/test/scala/org/perl8/test/tap/TestBuilderTest.scala')
-rw-r--r-- | src/test/scala/org/perl8/test/tap/TestBuilderTest.scala | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala index 08341e4..c527cd2 100644 --- a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala +++ b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala @@ -1,20 +1,14 @@ -package org.perl8.test +package org.perl8.test.tap -import org.scalatest.FunSuite -import org.scalatest.BeforeAndAfter +import org.perl8.test.TestMore -import org.perl8.test.tap.TestBuilder +import java.io.{OutputStream,ByteArrayOutputStream} -import java.io.ByteArrayOutputStream +import org.perl8.test.Utils._ -class TestBuilderTest extends FunSuite with BeforeAndAfter { - private val output = new ByteArrayOutputStream - - before { - output.reset - } - - test ("ok") { +class TestBuilderTest (out: OutputStream) extends TestMore(out) { + subtest ("ok") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(4, output) builder.ok(true, "test succeeded") builder.ok(false, "test failed") @@ -30,10 +24,11 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "not ok 4\n" + "# Looks like you failed 2 tests of 4.\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("no plan") { + subtest ("no plan") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.ok(true, "test succeeded") builder.ok(false, "test failed") @@ -49,10 +44,11 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "1..4\n" + "# Looks like you failed 2 tests of 4.\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("empty") { + subtest ("empty") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.doneTesting @@ -60,10 +56,11 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "1..0\n" + "# No tests run!\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("diag") { + subtest ("diag") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.ok(true, "the test passes") @@ -83,56 +80,67 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "1..3\n" + "# Looks like you failed 1 test of 3.\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("is passing") { + subtest ("is passing") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) - assert(!builder.isPassing) + ok(!builder.isPassing) builder.ok(true) - assert(builder.isPassing) + ok(builder.isPassing) builder.ok(false) - assert(!builder.isPassing) + ok(!builder.isPassing) builder.ok(true) - assert(!builder.isPassing) + ok(!builder.isPassing) } - test ("bail out") { + subtest ("bail out") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.ok(true) - val e = intercept[BailOutException] { + try { builder.bailOut("oh no!") + fail() + } + catch { + case e: BailOutException => { + is(e.message, "oh no!") + } + case _: Throwable => fail() } - assert(e.message === "oh no!") val expected = "ok 1\n" + "Bail out! oh no!\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("skip all") { + subtest ("skip all") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(SkipAll(), output) val expected = "1..0 # SKIP\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("skip all with reason") { + subtest ("skip all with reason") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(SkipAll("foo bar"), output) val expected = "1..0 # SKIP foo bar\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("skip") { + subtest ("skip") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.ok(false) @@ -147,10 +155,11 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "1..3\n" + "# Looks like you failed 1 test of 3.\n" - assert(output.toString === expected) + is(output.toString, expected) } - test ("todo") { + subtest ("todo") { + val output = new ByteArrayOutputStream val builder = new TestBuilder(output) builder.ok(false, "do a thing", todo = "not working yet") @@ -162,6 +171,6 @@ class TestBuilderTest extends FunSuite with BeforeAndAfter { "ok 2 # TODO is it?\n" + "1..2\n" - assert(output.toString === expected) + is(output.toString, expected) } } |