Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何修复:“;“未发现任何测试”;我什么时候有笔试?_Php_Phpunit - Fatal编程技术网

Php 如何修复:“;“未发现任何测试”;我什么时候有笔试?

Php 如何修复:“;“未发现任何测试”;我什么时候有笔试?,php,phpunit,Php,Phpunit,我正在学习phpunit,我编写了一个简单的测试,但当我尝试用console启动它时,它找不到它。我启动phpunit时使用:“./vendor/bin/phpunit” 这就是测试。它位于./tests/ ?php require 'app/ball.php'; class testBalls extends PHPUnit\Framework\TestCase { public $ballInstance; public function setUp() {

我正在学习phpunit,我编写了一个简单的测试,但当我尝试用console启动它时,它找不到它。我启动phpunit时使用:“./vendor/bin/phpunit”

这就是测试。它位于./tests/

?php


require 'app/ball.php';

class testBalls extends PHPUnit\Framework\TestCase
{
    public $ballInstance;

    public function setUp()
    {
        $this->ballInstance = new Ball();
    }

    public function testStealing(){
        $this->ballInstance->setBalls(100);

        $this->ballInstance->stealBall();

        $this->assertEquals(99,$this->ballInstance->getBalls());
    }
}
这是经过测试的php脚本。它位于./app/

<?php

class Ball{

    private $ballCount;


    public function getBalls(){
        return $this->ballCount;
    }

    public function setBalls($number){
        $this->ballCount = $number;
    }

    public function stealBall(){
        $this->ballCount = $this->getBalls()-1;
    }
}

测验

类测试球
应该是
类测试球

似乎不完整,是否在composer.json的psr中设置球?另外,
suffix=“Test.php”
将寻找
testtesttest.php
,假设这是测试意味着这是./tests/Test.phpHeres,这是我的一个蹩脚libs中的一个例子,它往往总是与phpunit.xml中的值相同。一旦设置,可能会有一些帮助。谢谢,我没有意识到类或文件的名称很重要。
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
         colors="true"
         verbose="true"
         stopOnFailure="false">

    <testsuites>
        <testsuite name="Test suite">
            <directory suffix="Test.php">tests</directory>
        </testsuite>
    </testsuites>
</phpunit>