无法在测试文件夹外运行PHPUnit

无法在测试文件夹外运行PHPUnit,php,codeigniter,phpunit,Php,Codeigniter,Phpunit,所以我有一个CodeIgniter项目,我正在尝试使用PHPUnit。我的目录看起来像 application node_modules Gruntfile.js scripts vendor tests PostTest.php phpunit.phar bootstrap.php phpunit.xml composer.json package.json 当我在tests文件夹中时,我可以执行“phpunit.”或“php phpunit.phar.”以在

所以我有一个CodeIgniter项目,我正在尝试使用PHPUnit。我的目录看起来像

application
node_modules
Gruntfile.js
scripts
vendor
tests
    PostTest.php
    phpunit.phar
    bootstrap.php
    phpunit.xml
composer.json
package.json
当我在tests文件夹中时,我可以执行“phpunit.”或“php phpunit.phar.”以在postest.php中运行测试,这很好,但是当我在根文件夹中,并尝试执行“phpunit测试”时,我会得到错误:

ERROR: Not Found

    The controller/method pair you requested was not found.
postest.php

<?php
class PostTest extends PHPUnit_Framework_TestCase {
      private $CI;

      public function setUp() {
          $this->CI = &get_instance();
      }

      public function testNotes() {
        $this->CI->load->model('class');
        $students = $this->CI->class->getStudents('11');
        $this->assertEquals(3, count($students->result_array()));
      }
}

Phpunit在当前目录中查找Phpunit.xml,并下放到目录中查找测试文件。因此,将此文件移动到webroot,您应该会被排序。或者,您可以在phpunit.xml中指定要运行测试的目录,并将其保留在原处,然后添加类似以下内容(未测试)以使其在webroot中包含测试:

<testsuites>
    <testsuite name="My Test Suite">
        <directory suffix="Test.php">../</directory>
    </testsuite>
</testsuites>

../

因此,我之前尝试将phpunit.xml移动到根目录中,当我这样做时,错误变为
致命错误:调用未定义函数get\u instance()在第7行的/Applications/XAMPP/xamppfiles/htdocs/project/tests/postest.php中
,我以前遇到过这个错误,但我无法找到解决这个问题的永久解决方案。@Jon-刚刚意识到这是CodeIgniter,我对CI项目的设置一无所知,所以我将退出。
<testsuites>
    <testsuite name="My Test Suite">
        <directory suffix="Test.php">../</directory>
    </testsuite>
</testsuites>