diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-02-20 18:53:29 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-02-20 18:53:29 -0600 |
commit | 98621ad7b07f076da65c7614227db4c8e33f6dde (patch) | |
tree | 54c883938489867dfa4c0b3b0f4a50d8c57f978f | |
parent | f86ee1fb6d591086f5d734850cff48a469dda8d5 (diff) | |
download | scala-test-more-98621ad7b07f076da65c7614227db4c8e33f6dde.tar.gz scala-test-more-98621ad7b07f076da65c7614227db4c8e33f6dde.zip |
handle mismatches plans
-rw-r--r-- | src/main/scala/org/perl8/test/TestBuilder.scala | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/scala/org/perl8/test/TestBuilder.scala b/src/main/scala/org/perl8/test/TestBuilder.scala index 6e754ad..61533a0 100644 --- a/src/main/scala/org/perl8/test/TestBuilder.scala +++ b/src/main/scala/org/perl8/test/TestBuilder.scala @@ -59,13 +59,25 @@ class TestBuilder ( } if (!isPassing) { + if (!state.matchesPlan) { + val planCount = (plan match { + case Some(p) => p.plan + case None => state.currentTest - 1 + }) + val planned = planCount + " test" + (if (planCount > 1) "s" else "") + val ran = state.currentTest - 1 + diag("Looks like you planned " + planned + " but ran " + ran + ".") + } + if (state.currentTest == 1) { diag("No tests run!") } - else { + + if (state.failCount > 0) { val count = state.failCount val fails = count + " test" + (if (count > 1) "s" else "") - val total = state.currentTest - 1 + val total = + state.currentTest - 1 + (if (state.matchesPlan) "" else " run") diag("Looks like you failed " + fails + " of " + total + ".") } } @@ -103,7 +115,12 @@ class TestBuilder ( def currentTest: Int = failCount + passCount + 1 + def matchesPlan: Boolean = plan match { + case Some(p) => p.plan == failCount + passCount + case None => true + } + def isPassing: Boolean = - currentTest > 1 && failCount == 0 + currentTest > 1 && failCount == 0 && matchesPlan } } |