Codeception/Codeception — pull request #55 by lostintime (2012-08-26 13:22:32+00:00)
Title: test generation (generate:test) and running fix

Generate test by running:

# codecept generate:test integration My

and it generates:

bootstrap) require $this->bootstrap;
$this->dispatcher->dispatch('test.before', new \Codeception\Event\Test($this));
$this->testGuy = new TestGuy($scenario = new \Codeception\Scenario($this));
$scenario->run();

// initialization code
}

protected function tearDown()
{
$this->dispatcher->dispatch('test.after', new \Codeception\Event\Test($this));
}

// tests
}

where

$scenario->run();

is probably wrong, because when I add one test method:

public function testSomething()
{
$this->testGuy->wantTo('test some code');
$this->testGuy->execute(function() {
return 'something';
});

$this->testGuy->seeExceptionThrown('MyException');
$this->testGuy->seeResultEquals('something else');
}

I got exception throw in Codeception/Module/Unit.php at line 424 with message:

New steps were added to scenario in realtime. Can't proceed. Remove loops from your unit test to fix it

and code 0.

which also can't be displayed because of "Fatal error: Call to undefined method MyTest::getTrace() in src/Codeception/Subscriber/Console.php on line 141"

The first problem can be fixed by removing "$scenario->run() from setUp() method", second - by copying getTrace method from Codeception\TestCase\Cept class to Codeception\TestCase\Test class.

Anyway - after fixing these problems - I got:

# codecept run integration

Codeception PHP Testing Framework v1.1.1
Powered by PHPUnit 3.6.10 by Sebastian Bergmann.

Suite integration started
Trying to test something (MyTest::testSomething) - Ok

Time: 1 second, Memory: 6.50Mb

OK (1 test, 0 assertions)

where we see 0 assertions - should be 2 and both failed:

$this->testGuy->seeExceptionThrown('MyException');
$this->testGuy->seeResultEquals('something else');

what I'm doing wrong? :)