示例#1
0
             return $suite->skipped();
         });
         ok(count($result) == 1);
     });
 });
 describe("case state", function () {
     before_each(function () {
         // start new env
         Preview::$world = $this->world;
         Preview::$config = $this->config;
         $exception_in_sample_code = null;
         // below is our test
         try {
             $suite = new Suite("sample suite");
             $suite->test("error", function () {
                 $a->value;
             })->test("failed", function () {
                 ok(false);
             })->test("passed", function () {
             })->test("skipped", "skip", function () {
             })->load();
             $this->results = $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;
         }
示例#2
0
 before_each(function () {
     $this->suite = new Suite("sample suite");
 });
 context("sample test suite", function () {
     before_each(function () {
         // start new env
         Preview::$world = $this->world;
         Preview::$config = $this->config;
         $exception_in_sample_code = null;
         // ------ test -------
         try {
             $this->suite->test("c1", function () {
             })->test("c2", "skip", function () {
             })->test("c3");
             $child = new Suite("child suite");
             $child->test("c4", function () {
             })->test("c5", "skip", function () {
             })->test("c6");
             $this->suite->add_child($child)->load();
             $this->results = $this->world->run();
             // ------ end test -------
         } 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;
         }
     });
     it("should have one child suite", function () {
示例#3
0
            // start new env
            Preview::$world = $this->world;
            Preview::$config = $this->config;
            // -- test start --
            $message = array();
            $total = 0;
            $suite = new Suite("sample suite");
            $suite->after(function () use(&$message, &$total) {
                $message[] = "after";
                $total++;
            });
            $suite->after_each(function () use(&$message) {
                $message[] = "then after_each";
            });
            $suite->test("add a new message", function () use(&$message) {
                $message[] = "it first";
            });
            $suite->test("add a new message", function () use(&$message) {
                $message[] = "it first";
            });
            $suite->load();
            $this->world->run();
            // -- test end --
            // end new env
            Preview::$world = $this->test_world;
            Preview::$config = $this->test_config;
            ok(end($message) == "after");
            ok($total == 1);
        });
    });
});