【发布时间】:2012-10-19 06:16:12
【问题描述】:
使用 phpunit,但我在包含路径方面遇到了一些问题,不是针对 phpunit 本身,而是针对我的代码和测试目录。
我的代码结构如下:
Application
-StringCalculator.php
tests
-StringCalculatorTest.php
在我的 StringCalculatorTest.php 中,我有一个 require 语句:
require_once('../StringCalculator.php');
在测试文件夹中运行phpunit StringCalculatorTest.php 效果很好。
但是,当我随后在根目录中引入一个 phpunit.xml 配置文件时,即
Application
-StringCalculator.php
tests
-StringCalculatorTest.php
phpunit.xml
包含路径被搞砸了。我必须将 require_once 替换为
require_once('StringCalculator.php');
在应用程序和测试目录之间设置包含路径的正确方法是什么?
【问题讨论】:
标签: php unit-testing phpunit