Laravel 8 Unit Test

Laravel crea i test in due directory:

./tests/Feature
./test/Unit
php artisan make:test MyTest   # integration test
php artisan make:test MyTest  --unit
 
# execute tests
php artisan test

file /test/Feature/MyTest.php

class MyTest extends TestCase {
    // integration test
    public function test_example() {
        $response = $this->get('/');
        $response->assertStatus(200);
    }
    // unit test
    public function test_Number() {
        $m = new Money(10, 7);
        $m->add( new Money(1, 3) );
        $this->assertTrue( $m->toStr() === '12.00' );
    }
}

run with:

php artisan test

Tags:
PHP Laravel

Blog Disclaimer:

Le opinioni espresse nel mio blog sono solo questo: mie opinioni.

In nessun modo rappresento le opinioni dei miei clienti in questa sede.