Problems with Unit Testing - HTTP Feature Testing - CI4 |
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>
Your testcase should be in the App namespace. Not sure if that will solve the problem, but it's a start.
(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
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 {...} (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? |
Welcome Guest, Not a member yet? Register Sign In |