Browse files

Simple test for unit itself

  • Loading branch information...
1 parent 7228141 commit 60d1d3848d4ff910ef06f3018722a6e91c2f7976 @krukow krukow committed Oct 26, 2011
Showing with 67 additions and 0 deletions.
  1. +49 −0 dunit/tests/TestRunnerTest.dart
  2. +18 −0 dunit/tests/test_runner.dart
View
49 dunit/tests/TestRunnerTest.dart
@@ -0,0 +1,49 @@
+class TestRunnerTest extends TestCase {
+ TestRunnerTest():
+ super("TestRunnerTestCase"),
+ setup_called=false,
+ test_count=0,
+ teardown_called=false;
+
+ bool setup_called;
+ int test_count;
+ bool teardown_called;
+ setUp() {
+ setup_called=true;
+ }
+ tearDown() {
+ Map t = tests();
+ Expect.equals(t.length,test_count);
+ teardown_called=true;
+ }
+
+ tests() => {
+ "A": () { Expect.isTrue(setup_called); test_count++;},
+ "B": () { Expect.isTrue(setup_called); test_count++;},
+ "C": () { Expect.isTrue(setup_called); test_count++;}
+ };
+}
+
+class MetaTest extends TestCase {
+ TestRunnerTest t;
+ bool setup_called = false;
+ bool test_called = false;
+ setUp() {
+ setup_called = true;
+ t = new TestRunnerTest();
+ }
+ tests() => {
+ "Test case run": () {
+ test_called = true;
+ var r = new TestRunner();
+ TestResult tr = r.run(t);
+ Expect.isTrue(tr.noDefects());
+
+ Expect.isTrue(t.setup_called);
+ Expect.isTrue(t.teardown_called);
+
+
+
+ }
+ };
+}
View
18 dunit/tests/test_runner.dart
@@ -0,0 +1,18 @@
+#library("contrib.dunit.tests.runner");
+
+#import("../dunit_base.dart");
+#import("../../pprint/pprint.dart");
+
+#source("TestRunnerTest.dart");
+
+main() {
+ var tr = new TestRunner();
+ var t = new MetaTest();
+ var res = tr.run(t);
+ Expect.isTrue(t.setup_called);
+ Expect.isTrue(t.test_called);
+ pp(res.results);
+ pp(res.results[t]['result'].results);
+
+
+}

0 comments on commit 60d1d38

Please sign in to comment.