0

私は必死にZend Framework 1.11でPHPUnitを動作させようとしています。私の phpunit.xml では、それが指している場所を確認する必要があります。

<phpunit bootstrap="./bootstrap.php" colors="false">
    <testsuite name="ApplicationTestSuite">
        <directory>./application</directory>
        <directory>./library/</directory>
    </testsuite>
    <filter>
        <whitelist>
            <directory suffix=".php">../application</directory>
            <directory suffix=".php">../library/</directory>
            <exclude>
                <directory suffix=".phtml">../applications/views</directory>
                <file>../applications/Bootstrap.php</file>
            </exclude>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./log/coverage" charset="UTF-8"
             yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
    </logging>
</phpunit>

このすべて:

./Application
 ./library
 ../application/Bootstrap.php

アプリケーション ディレクトリではなく、 tests ディレクトリを指しますよね?

私は常に致命的なエラーを抱えているため:require_once:必要なcontrollerTestCase.phpを開くのに失敗しました...

あなたの助けを前もって感謝します

4

1 に答える 1

0

まずBootstrap.php、アプリを通常どおり実行するためのファイルとテスト用のファイルの 2 つを用意することができます。ディレクトリのレベルでtestsディレクトリを作成します。あなたはその新しいディレクトリに存在します。これは、ディレクトリの内部がどのように見えるかです: Applicationphpunit.xmltests

./Application/
./Application/Bootstrap.php
./Application/ExampleControllerTestCase.php
./log/
./phpunit.xml

そしてあなたのphpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Application/Bootstrap.php" colors="true">
    <testsuite name="ExampleTests">
        <directory>./Application</directory>
    </testsuite>

    <filter>
        <whitelist>
            <directory suffix=".php">../Application/</directory>
            <exclude>
                <directory suffix=".phtml">../Application/</directory>
                <file>../Application/Bootstrap.php</file>
            </exclude>
        </whitelist>
    </filter>

    <logging>
        <log type="coverage-html" target="log/" charset="UTF-8" yui="true" hightlight="true" lowupperbound="50" highlowerbound="80">
        <log type="testdox" target="log/">
    </log></log></logging>
</phpunit>

次の点に注意してください。

  1. ディレクトリ内のファイルへの<phpunit bootstrap="./application/Bootstrap.php" colors="true">ポイント。Bootstrap.phptests/Application/

  2. 「ホワイトリストに登録された」アプリケーション ディレクトリは、上位レベルのディレクトリです。つまり、ディレクトリと同じ位置にありtestsます。

  3. .phtmlファイルと「ランタイム」Bootstrap.phpは除外されます。

一部のテストではデータの削除/挿入/更新が必要なため、テスト データベースも必要です。あなたの場合、「testsuite」タグは、そのディレクトリにある場合、そのディレクトリtestsを指しphpunit.xmlます。

于 2013-05-28T09:47:30.413 に答える