简体   繁体   中英

PHPUnit Tests Not Being Executed

I have the following code in PHP and when I run it through phpunit, I get back a message about "No tests executed!"

<?php

use PHPUnit\Framework\TestCase;


class Calculator

{

    public function add($a, $b)
    {
        return $a + $b;
    }

}


class CalculatorTest
{
    private $calculator;

    public function setUp()
    {
        $this->calculator = new Calculator();
    }

    public function tearDown()
    {
        $this->calculator = NULL;
    }

    public function test_Add_1and2_Expect3()
    {
        $result = $this->calculator->add(1, 2);
        $this->assertEquals(3, $result);
    }

}


?>


I even tried putting the Calculator class into it's own file and provided the line /require '/home/Documents/PHPTests/calculator/src/Calculator.php'; but still that doesn't work. I'm using PHPUnit version 8.4.3. Thanks in advance.

添加这一行:

class CalculatorTest extends TestCase

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM