$this->config = new Configuration(); $this->config->reporter = new \Recorder(); }); context("sample test suite", function () { before_each(function () { // 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); });
Preview::$config = $this->test_config; if ($exception_in_sample_code) { throw $exception_in_sample_code; } ok($message == array("setup first", "then test", "setup first", "then test")); }); }); describe("#teardown", function () { 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;