Need help with Test |
Hello,
I just learn PHPUnit (i am newbie for test suite). I try setting PHPUnit on netbeans project. I try following user guide. But no success. First, Fatal error: Class 'Test\CIUnitTestCase' not found I modify the test/_support/CIUnitTestCase.php adding : require 'system/Test/CIUnitTestCase.php'; Then another error not found I just think the path for testing not set properly. Where the file for set this path (for testing)?
Any people can answer this? The problem is broken path. Where to fix this?
I suppose the test is run from project root folder
(08-27-2018, 06:33 AM)ciadmin Wrote: Have you checked https://github.com/bcit-ci/CodeIgniter4/...elop/tests Yes, I have. I have already installed PHPUnit globally. It works on simple projects. But I have trouble to configure it for CI4
You mentioned netbeans, which I also use. However, all my unit testing is done from the command line. If you have phpunit installed globally, then you shuld be able to run "phpunit"
from your project root, with no changes to any CI code, and have the tests complete successfully.
These the output:
Code: H:\wamp306_x64\www\CodeIgniter4-develop>php phpunit-7.3.0.phar -c phpunit.xml UnitTest tests\system\CommonFunctionsTest.php How is your CLI command btw?
have an similar problem when i dont set the correct working directory ( which has to be the project directory ). But dont know how to set it via cli, sry.
my execution command is (all): Code: "C:\PHP Server\7.2.3_TS_64\php.exe" C:/Repos/FlamingaWeb3/vendor/phpunit/phpunit/phpunit --configuration C:\Repos\FlamingaWeb3\phpunit.xml.dist --teamcity (spec): Code: "C:\PHP Server\7.2.3_TS_64\php.exe" C:/Repos/FlamingaWeb3/vendor/phpunit/phpunit/phpunit --configuration C:\Repos\FlamingaWeb3\phpunit.xml.dist --filter "/(::testListFilesWithoutPath)( .*)?$/" CodeIgniter\Autoloader\FileLocatorTest C:\Repos\FlamingaWeb3\tests\system\Autoloader\FileLocatorTest.php --teamcity
(08-29-2018, 12:14 AM)puschie Wrote: have an similar problem when i dont set the correct working directory ( which has to be the project directory ). But dont know how to set it via cli, sry. Working directory means folder where you work. Code: C:\>cd [CodeIgniterRoot] Supposed showcwd.php PHP Code: <?php I also create _bootstrapshow.php which like _bootstrap, but echoing every defined constant to verify the path. It shows correct path, but it can't recognize namespace CodeIgniter\Test;
So no one knows how to repair the missing path then?
I can always include absolute path, but it needs to be included on every file. not good solution
the cli command for my environment is :
Code: C:\Repos\FlamingaWeb3>"C:\PHP Server\7.2.3_TS_64\php.exe" C:\Repos\FlamingaWeb3\vendor\phpunit\phpunit\phpunit --configuration C:\Repos\FlamingaWeb3\phpunit.xml.dist pls try to customize the command for your usage ( just change the paths ). specific command for single test file : Code: C:\Repos\FlamingaWeb3>"C:\PHP Server\7.2.3_TS_64\php.exe" C:\Repos\FlamingaWeb3\vendor\phpunit\phpunit\phpunit --configuration C:\Repos\FlamingaWeb3\phpunit.xml.dist CodeIgniter\Autoloader\FileLocatorTest C:\Repos\FlamingaWeb3\tests\system\Autoloader\FileLocatorTest.php if this will not work, something is wrong with your environment - try to use the codeigniter phpunit, which can be loaded by composer |
Welcome Guest, Not a member yet? Register Sign In |