Problems with Unit Testing - HTTP Feature Testing - CI4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Problems with Unit Testing - HTTP Feature Testing - CI4 (/showthread.php?tid=72758) |
Problems with Unit Testing - HTTP Feature Testing - CI4 - CiUser - 02-07-2019 Hello, i'm trying to make a simple test using 'HTTP Feature testing' as described in Documentation. But, after hours of trying I couldn't achieve it. This is my implementation class: PHP Code: <?php And this is my Test class: PHP Code: <?php And this is the error thrown: Code: There was 1 error: In my phpunit.xml, i've defined my env app.baseUrl as: Code: <php> RE: Problems with Unit Testing - HTTP Feature Testing - CI4 - ciadmin - 02-08-2019 Your testcase should be in the App namespace. Not sure if that will solve the problem, but it's a start. RE: Problems with Unit Testing - HTTP Feature Testing - CI4 - CiUser - 02-08-2019 (02-08-2019, 08:53 AM)ciadmin Wrote: Your testcase should be in the App namespace. Not sure if that will solve the problem, but it's a start. Okay, but, in documentation seems to indicate that the namespace should be 'Tests',isn't it? I consider that if my testcase is inside /tests make sense that namespace be 'Tests' rather than 'App' Though in HTTP Testing section indicates that namespace should be 'App'. I'm a bit confused with that RE: Problems with Unit Testing - HTTP Feature Testing - CI4 - ciadmin - 02-08-2019 Ah - I see the contradiction. I think the testing writeup is incorrect. The tests/ folder just isolates test code from "real" code. I will experiment, & adjust the docs if needed. My expectation would be: <? php namespace App; class MyAppTest extends \CIUnitTestCase {...} RE: Problems with Unit Testing - HTTP Feature Testing - CI4 - CiUser - 02-15-2019 (02-08-2019, 10:35 AM)ciadmin Wrote: Ah - I see the contradiction. I think the testing writeup is incorrect. The tests/ folder just isolates test code from "real" code. I will experiment, & adjust the docs if needed. After debug the code I got the core of the error. For some reason class_exists not found 'App\Controllers\\Home' because of the first backslash in the namespace (App\Controllers) should be escaped as the second one (Controllers\\Home). So, the controller is not found. Is there some config that I'm forgetting to to set or what could be the problem with that behaviour? |