0

While my other Codeception tests are running (acceptance, api, etc,), very little of the unit tests will run. It does not see any tests of type Test.php, only Cept.php and Cest.php. It does not accept (errors) any assertion tests such as "$this->assertEquals($expeced. 'expect this'). How do I trouble shoot this as the tests that fail only return: Codeception PHP Testing Framework v1.8.1 Powered by PHPUnit 3.7.28 by Sebastian Bergmann.

phpunit seems to be installed as I see it in the vendor directory. I can run it directly from the command line to see its help. But that is about it. Are unit tests generally flaky with the Laravel/Codeception combo? Is there some config I am missing???

user3061986
  • 75
  • 1
  • 9
  • Did you name the functions of the unit tests with a test prefix? For example public function testGet()? – Matthias Loibl Dec 08 '13 at 19:49
  • Yes. It just does not seem to be finding phpunit. It will error and return Call to undefined method SampleCest::assertEquals() in /Users/falaco/sites/acme/app/tests/unit/SampleCest.php:36 – user3061986 Dec 08 '13 at 20:05
  • Could you paste the test function maybe at paste.laravel.com? – Matthias Loibl Dec 08 '13 at 20:16
  • Here is a very simple test http://paste.laravel.com/1cRc that fails when I test for assertEquals. It cannot find the method assertEquals. Perhaps $this is not right. – user3061986 Dec 08 '13 at 20:23
  • all assert tests cause errors as the methods are not being seen. So it must be some sort of phpUnit codeception laravel 4 config issue. But I do not see how to troubleshoot it. – user3061986 Dec 08 '13 at 20:26

1 Answers1

0

Seems like the problem was the creation of the test class.

You declared you want to use \CodeGuy; - you don't want to do that.

Instead you want to extend your class like this.

class SampleCest extends \Codeception\TestCase\Test

My advise: use codeception to generate your unit tests.

codecept.phar generate:phpunit unit Sample
Matthias Loibl
  • 863
  • 1
  • 8
  • 19
  • That did not work, same thing. The generated tests do not work. – user3061986 Dec 08 '13 at 23:38
  • I solved this by installing Jeffery Way's phpunit wrappers. Now I can test using Way's assertion syntaz and it works. Still not sure what the problem was, but I wish there was a better way of debugging in that situation. – user3061986 Dec 09 '13 at 00:27
  • You had no valid CodeCeption Unit Test class. I've tried to fix it and pasted your code into a, from codeception, generated class. I think you inherited wrong. Can't remember anymore. – Matthias Loibl Dec 11 '13 at 21:23