CodeIgniter Forums
CodeIgniter 4 Testing Problems - 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: CodeIgniter 4 Testing Problems (/showthread.php?tid=76778)



CodeIgniter 4 Testing Problems - mr-dev - 06-19-2020

Hi,

I'm new to CodeIgniter 4 and testing. I am developing my project using this framework.
I'm having hard time trying to get my tests to run.

I have used app starter to start the project

Yes I searched the forum for answers.
Yes basic sample tests are running fine
Yes I have read the docs
Yes I configured .env file to development
Yes I looked through sample tests attached.

I'm getting PHPunit warnings:

1) Warning

No tests found in class "CodeIgniter\Test\FeatureTestCase".


Then i get error on my test like:
1) App\FeatureTests\TestIndex::testIfIndexDisplaysLoginPage

ErrorException: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time


Maybe someone more experienced can assist me:
I wrote my first basic test to feature test first http response from where my user lands on login page like this:

PHP Code:
<?php namespace App\FeatureTests;

use 
CodeIgniter\Test\FeatureTestCase;

class 
TestIndex extends FeatureTestCase
{
    public function setUp(): void
    
{
        parent::setUp();
    }

    public function tearDown(): void
    
{
       parent::tearDown();
    }

    public function testIfIndexDisplaysLoginPage()
    {
        $result $this->get('/');

        $result->assertContains('Please sign in');
    }


Any ideas or suggestions?


RE: CodeIgniter 4 Testing Problems - WebboyFR - 03-18-2021

Hello, I got the same problem. Did you find a solution ? Thanks


RE: CodeIgniter 4 Testing Problems - paulbalandan - 03-18-2021

Try renaming your test class to IndexTest