Example #1
0
        it("should run after each test", function () {
            // start new env
            Preview::$world = $this->world;
            Preview::$config = $this->config;
            $exception_in_sample_code = null;
            try {
                $message = array();
                qunit\suite("sample suite");
                qunit\teardown(function () use(&$message) {
                    $message[] = "then teardown";
                });
                qunit\test(function () use(&$message) {
                    $message[] = "test first";
                });
                qunit\test(function () use(&$message) {
                    $message[] = "test first";
                });
                $this->world->run();
            } catch (\Exception $e) {
                $exception_in_sample_code = $e;
                // end new env
            }
            Preview::$world = $this->test_world;
            Preview::$config = $this->test_config;
            if ($exception_in_sample_code) {
                throw $exception_in_sample_code;
            }
            ok($message == array("test first", "then teardown", "test first", "then teardown"));
        });
    });
});
Example #2
0
     // start new env
     Preview::$world = $this->world;
     Preview::$config = $this->config;
     // ------ test -------
     qunit\suite("s1");
     qunit\test("c1", function () {
     });
     qunit\test("c2", function () {
     })->skip();
     qunit\test("c3");
     qunit\suite("s2");
     qunit\test(function () {
     });
     qunit\test("c5", function () {
     })->skip();
     qunit\test("c6");
     $this->results = $this->world->run();
     // ------ end test -------
     // end new env
     // and go back to our normal test env
     Preview::$world = $this->test_world;
     Preview::$config = $this->test_config;
 });
 it("should have 2 suite", function () {
     ok(count($this->results) == 2);
 });
 it("first suite should have 3 test cases", function () {
     ok(count($this->results[0]->cases()) == 3);
 });
 it("second suite should have 3 test cases", function () {
     ok(count($this->results[1]->cases()) == 3);
Example #3
0
     // below is our test
     qunit\suite("sample suite");
     qunit\test("error", function () {
         $a->value;
     });
     qunit\test("failed", function () {
         ok(false);
     });
     qunit\test("passed", function () {
     });
     qunit\test(function () {
     });
     qunit\test("pending");
     qunit\test("skipped", function () {
     })->skip();
     qunit\test("pending cannot skipped")->skip();
     $this->results = $this->world->run();
     // end new env
     // and go back to our normal test env
     Preview::$world = $this->test_world;
     Preview::$config = $this->test_config;
 });
 it("sample should have 1 testsuite result and 7 testcase", function () {
     ok(count($this->results) == 1);
     ok(count($this->results[0]->all_cases()) == 7);
 });
 it("sample should have one error test result", function () {
     $all = $this->results[0]->all_cases();
     $result = array_filter($all, function ($case) {
         return $case->error();
     });