aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-03-14 11:41:34 -0500
committerJesse Luehrs <doy@tozt.net>2013-03-14 11:46:18 -0500
commit7a00ccf0a468cd74543e3c65f8ebecab9629e10d (patch)
treee6f352e77b84bdd7deb97279d76e2ee6a82b130c
parentbc9d8f9e68f80d195b41e6a19d8bf2f505f59dad (diff)
downloadscala-test-more-7a00ccf0a468cd74543e3c65f8ebecab9629e10d.tar.gz
scala-test-more-7a00ccf0a468cd74543e3c65f8ebecab9629e10d.zip
diag and note should be able to stringify anything
fixes gh-1
-rw-r--r--src/main/scala/com/iinteractive/test/TestMore.scala4
-rw-r--r--src/main/scala/com/iinteractive/test/tap/TestBuilder.scala8
-rw-r--r--src/test/scala/com/iinteractive/test/TestMoreTest.scala3
-rw-r--r--src/test/scala/com/iinteractive/test/tap/TestBuilderTest.scala21
4 files changed, 23 insertions, 13 deletions
diff --git a/src/main/scala/com/iinteractive/test/TestMore.scala b/src/main/scala/com/iinteractive/test/TestMore.scala
index eb5210b..b5bf6f4 100644
--- a/src/main/scala/com/iinteractive/test/TestMore.scala
+++ b/src/main/scala/com/iinteractive/test/TestMore.scala
@@ -302,7 +302,7 @@ class TestMore (plan: Plan = NoPlan) extends Test with DelayedInit {
*
* @example `diag("Testing with Scala " + util.Properties.versionString)`
*/
- def diag (message: String) {
+ def diag (message: Any) {
builder.diag(message)
}
@@ -311,7 +311,7 @@ class TestMore (plan: Plan = NoPlan) extends Test with DelayedInit {
*
* @example `note("Starting the response tests")`
*/
- def note (message: String) {
+ def note (message: Any) {
builder.note(message)
}
diff --git a/src/main/scala/com/iinteractive/test/tap/TestBuilder.scala b/src/main/scala/com/iinteractive/test/tap/TestBuilder.scala
index 62fdf02..17c2a9d 100644
--- a/src/main/scala/com/iinteractive/test/tap/TestBuilder.scala
+++ b/src/main/scala/com/iinteractive/test/tap/TestBuilder.scala
@@ -75,15 +75,15 @@ class TestBuilder private (
* visible in most summarizing harnesses (which consume and parse
* everything that goes to `Console.out`).
*/
- def diag (message: String) {
- errLine(Producer.comment(message))
+ def diag (message: Any) {
+ errLine(Producer.comment(message.toString))
}
/** Write a comment line to `Console.out`. This will typically only be
* visible in the raw TAP stream.
*/
- def note (message: String) {
- outLine(Producer.comment(message))
+ def note (message: Any) {
+ outLine(Producer.comment(message.toString))
}
/** Abort the current test, with a message. */
diff --git a/src/test/scala/com/iinteractive/test/TestMoreTest.scala b/src/test/scala/com/iinteractive/test/TestMoreTest.scala
index ead9823..22bddc3 100644
--- a/src/test/scala/com/iinteractive/test/TestMoreTest.scala
+++ b/src/test/scala/com/iinteractive/test/TestMoreTest.scala
@@ -55,6 +55,8 @@ class TestMoreTest extends TestMore {
fail("it doesn't work")
fail
}
+
+ diag(List(1, "foo"))
}
val out = new ByteArrayOutputStream
@@ -140,6 +142,7 @@ class TestMoreTest extends TestMore {
"# at TestMoreTest.scala line " + line(44) + ".\n" +
"not ok 23 # TODO not working yet\n" +
"# Failed (TODO) test at TestMoreTest.scala line " + line(45) + ".\n" +
+ "# List(1, foo)\n" +
"1..23\n" +
"# Looks like you failed 9 tests of 23.\n"
diff --git a/src/test/scala/com/iinteractive/test/tap/TestBuilderTest.scala b/src/test/scala/com/iinteractive/test/tap/TestBuilderTest.scala
index bc873c8..b1f23c9 100644
--- a/src/test/scala/com/iinteractive/test/tap/TestBuilderTest.scala
+++ b/src/test/scala/com/iinteractive/test/tap/TestBuilderTest.scala
@@ -70,6 +70,9 @@ class TestBuilderTest extends TestMore {
}
subtest ("diag") {
+ class Foo {
+ override def toString = "stringified"
+ }
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
@@ -78,19 +81,23 @@ class TestBuilderTest extends TestMore {
builder.ok(false, "the test passes")
builder.diag("got false, expected true")
builder.ok(true)
+ builder.diag(List(1, "foo", Nil, ('a', 2.3)))
+ builder.diag(new Foo)
builder.diag("ending\nnow")
builder.doneTesting
}
}
val expected =
- "ok 1 the test passes\n" +
- "not ok 2 the test passes\n" +
- "# got false, expected true\n" +
- "ok 3\n" +
- "# ending\n" +
- "# now\n" +
- "1..3\n" +
+ "ok 1 the test passes\n" +
+ "not ok 2 the test passes\n" +
+ "# got false, expected true\n" +
+ "ok 3\n" +
+ "# List(1, foo, List(), (a,2.3))\n" +
+ "# stringified\n" +
+ "# ending\n" +
+ "# now\n" +
+ "1..3\n" +
"# Looks like you failed 1 test of 3.\n"
is(output.toString, expected)