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???
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
Related
Using Codeception acceptance tests I need to check some behaviors with and without Javascript. Right now, using Seleniun I can run all tests with Javascript enabled, and using PhpBrowser I can run all tests without javascript. But how can I do for running some tests with javascript and some tests without javascript?
Codeception has several methods of sorting tests:. "groups" "environments" and "suites". Either environments or suites could be used to run tests acceptance tests with different drivers. You can create a new suite on the command line with
codecept generate suite mySuite
Then just modify mySuite.yml and you're good to go.
I have defined two test-suites in phpunit.xml file, one for Unit Tests and other for Functional Test. For some functions which can't be unit tested, I am using #codeCoverageIgnore in my source code. But I do not want this code to be ignored when running Functional Tests.
Is it possible to add test-suite name to codeCoverageIgnore so that my code is ignored for unit tests and not for functional tests.
No, that is not possible. If you think it should be possible then please open a ticket.
Sorry for the basic nature of this question but I've tried figuring this out through phpunit docs and online searching but can't piece it together.
I have a number of php classes that I would like to test against via a phpunit cli interface script (windows box) but I'm stuck on a very basic thing.
my test subjects are, e.g., c:\src\classes and test files are here, c:\src\tests
I can run individually by doing the following:
$> phpunit --bootstrap c:\src\classes\<name of class subject> c:\src\tests\<name of test file>
what I want to be able to is:
$> phpunit --bootstrap <something that registers multiple class subjects> c:\src\tests
so it would run against all tests in the c:\src\tests directory.
I've found references to the phpunit.xml that would be read prior to each phunit execution which I assume is where I could provide information about where the classes are for the tests, but all references that I've found to this has been unhelpful and have sent me down a couple of rat holes. Could someone point me to documentation that shows this configuration in plain black and white?
thanks!
What you should pass to --bootstrap is the path of a PHP script that registers an autoloader that is responsible for loading (only) your classes.
Such an autoloader can be created using a tool like phpab. Composer also generates an autoloader for you when you use it to manage the dependencies of your project.
Is it possible to with two different testing methodologies? For example PHPUnit and PHPSpec in the one applicationor package?
Does anyone have any guidance?
It is possible to use PHPSpec and PHPUnit in the same application. Or you could use something like Codeception (http://codeception.com/) which does Unit Testing, Functional Testing and Acceptance Testing all in one package.
I noticed that symfony automatically creates functional tests for all module actions, but i'm curious if it creates unit tests too. Maybe through a plugin or something.
The functional tests you mean are stubs - they do a very basic test, nothing else. There is no way to get unit or functional tests autogenerated for you - how would symfony know what's the expected behaviour of your appication?