【发布时间】:2014-12-30 09:41:49
【问题描述】:
我有一段代码显示为未涵盖,即使我有一个特定的测试来触发它。代码如下:
private function processConfiguration($baseFileName, ConfigurationInterface $definition)
{
$fileName = $this->createEnvironmentSpecificFileName($baseFileName);
$processor = new Processor();
$configuration = $this->loader->load($fileName);
if (is_null($configuration) === true) {
throw new \UnexpectedValueException('The configuration file can not be empty.');
}
return $processor->processConfiguration($definition, $configuration);
}
并且专门为使该函数抛出异常而进行的单元测试:
public function testGetQueueSettingsWithEmptyFile()
{
$this->setExpectedException('UnexpectedValueException');
$loader = $this->mockLoaderWith([], null, 0);
(new Reader($loader))->getQueueSettings();
}
然而,即使这个单元测试通过了,当我使用可能从 PHPUnit 获取报告的 Codeception 获取覆盖率报告时,此行是红色的:
throw new \UnexpectedValueException('The configuration file can not be empty.');
为什么?
【问题讨论】:
标签: unit-testing phpunit code-coverage xdebug codeception