CodeIgniter Forums
My first test.... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: My first test.... (/showthread.php?tid=89260)



My first test.... - trunky - 01-31-2024

I was going to write my first test ever and failed already... from the docs I found this piece and saved it at tests/app/Libraries/fooTest.php
PHP Code:
<?php

namespace App\Libraries;

use 
CodeIgniter\Test\CIUnitTestCase;

class 
FooTest extends CIUnitTestCase
{
    public function testFooNotBar()
    {
        $response $this->get('/');
    }

When I run the test now via 'vendor/bin/phpunit' I get the error message

Code:
There was 1 error:

1) App\Libraries\FooTest::testFooNotBar
Error: Call to undefined method App\Libraries\FooTest::get()

/var/www/html/bofewo/web/tests/app/Libraries/fooTest.php:11
So apparently I am missing something but not experienced enough to know what. Can someone point me the right direction please?


RE: My first test.... - kenjis - 01-31-2024

Quote:Feature testing requires that all of your test classes use the CodeIgniter\Test\DatabaseTestTrait and CodeIgniter\Test\FeatureTestTrait traits.
https://codeigniter4.github.io/CodeIgniter4/testing/feature.html#the-test-class