dongmu1989 2018-04-27 22:58 采纳率: 0%
浏览 109

phpunit“没有执行测试”

我无法通过PHPUnit中的测试解决问题。 这是我的代码,存在某些错误。 这是年度百分比率计算(https://en.wikipedia.org/wiki/Annual_percentage_rate)。 在cmd中:

    C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg>phpunit
PHP Warning:  Module 'oci8' already loaded in Unknown on line 0

Warning: Module 'oci8' already loaded in Unknown on line 0
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg\phpunit.xml



Time: 74 ms, Memory: 2.00MB

No tests executed!

C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg>

不要考虑Oracle模块,这是另一件事。 我在“ composer install”之后运行了“ phpunit”.

project/tests/test-general.php:

    <?php

use MotorK\{ Rate, Tae, Taeg };

class TestTaeg extends \PHPUnit\Framework\TestCase {

    /**
     * Example from http://www.calcolatoremutui.it/tan-e-taeg/
     */
    public function test_tae() {
        $obj = Tae::init( 5, 12 );

        $this->assertEquals( 5.116, round( $obj->calculate(), 3 ) );

        $this->expectOutputString( '5.116 %' );
        echo $obj;
    }

    /**
     * Example from http://www.calcolatoremutui.it/tan-e-taeg/
     */
    public function test_rate() {
        $obj = Rate::init( 100000, 5, 12, 20 );

        $this->assertEquals( 659.96, round( $obj->calculate(), 2 ) );

        $this->expectOutputString( '659.96 €' );
        echo $obj;
    }

    /**
     * Example from http://www.calcolatoremutui.it/tan-e-taeg/
     */
    public function test_taeg() {
        $obj = Taeg::init( 99000, 5, 661.96, 12, 20 );

        $this->assertEquals( 5.281, round( $obj->calculate(), 3 ) );

        $this->expectOutputString( '5.281 %' );
        echo $obj;
    }
}

project/phpunit.xml

<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuite name="Internal tests">
    <directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
<groups>
    <include>
        <group>default</group>
    </include>
</groups>
<filter>
    <whitelist>
        <directory suffix=".php">./includes/</directory>
    </whitelist>
</filter>

我尝试了很多次,但是仍然不能解决这个问题。

  • 写回答

2条回答 默认 最新

  • dongshou2024 2018-04-28 05:45
    关注

    The suffix (not the prefix) of a test case class' name must be Test. And the sourcecode file's name must match the class name.

    In your example, you probably want TaegTest (instead of TestTaeg) declared in TaegTest.php (instead of test-general.php).

    Also note that the version of PHPUnit you use has reached its end of life years ago. Read this to get started working with a recent version of PHPUnit.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度