2

我想知道是否可以为单元测试分配名称,以便它显示为运行。因此,如果我有多个测试都在运行一个失败的名称,可以很快找到

所以添加类似的东西(这不是真正的代码,它放在下面是为了描述目的)。它标记为 1.1 和 1.2 的部分我希望在控制台中输出

$this->assertEquals(1, 
   $crawler->filter('h1:contains("About symblog")')->count(), 
  '1.1 Test one some description'
);


$this->assertEquals(1, 
  $crawler->filter('h2:contains("' . $blogTitle .'")')->count(), 
  '1.2 Another test'
);

我不知道该怎么做。下面的实际代码

    public function testIndex()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/blogger/');

        // Check there are some blog entries on the page
        $this->assertTrue($crawler->filter('article.blog')->count() > 0);


        // Find the first link, get the title, ensure this is loaded on the next page
        $blogLink   = $crawler->filter('article.blog h2 a')->first();
        $blogTitle  = $blogLink->text();
        $crawler    = $client->click($blogLink->link());

        // Check the h2 has the blog title in it
        $this->assertEquals(1, $crawler->filter('h2:contains("' . $blogTitle .'")')->count());

    }

phpUnit 输出示例

4

1 回答 1

2

只需像这样使用--debug标志:

phpunit -c app --debug path/to/your/tests
于 2013-02-07T17:37:17.883 回答