本文介绍了忽略/忽略phpunit.xml中的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel,我只想运行一个测试文件,并且不想重命名或编辑整个测试代码,最方便的地方是指定要忽略的内容以及为我运行的内容是phpunit.xml所以我这样做了:

I am using Laravel and I want to run just one test file, and don't want to rename or edit all over test code, the most convenient place to specify what to ignore and what to run for me is phpunit.xml so I did this:

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit backupGlobals="false"
             backupStaticAttributes="false"
             bootstrap="bootstrap/autoload.php"
             colors="true"
             convertErrorsToExceptions="true"
             convertNoticesToExceptions="true"
             convertWarningsToExceptions="true"
             processIsolation="false"
             stopOnFailure="false"
             syntaxCheck="false">
        <testsuites>
            <testsuite name="Application Test Suite">
                <!--<directory>./tests/</directory>-->
                <file>./tests/RunJustThisTest.php</file>
            </testsuite>
        </testsuites>
        <php>
            <env name="APP_ENV" value="testing"/>
            <env name="CACHE_DRIVER" value="array"/>
            <env name="SESSION_DRIVER" value="array"/>
        </php>
    </phpunit>

如您所见,我注释掉了./tests/文件夹,但是其中的所有文件仍在运行,这很荒谬,我什至不知道phpunit还在哪里获取该文件夹的路径???我只想运行/tests/RunJustThisTest.php文件.而且我想在phpunit.xml文件中指定它,而不是在控制台中或弄乱代码.

As you see I commented out ./tests/ folder but all files from it are still being run which is absurd, I don't know even where else is phpunit getting path to that folder??? I want to run just /tests/RunJustThisTest.php file. And I want to specify it in phpunit.xml file, not console or messing in code.

我在Netbeans中加载了phpunit.xml文件.

I load phpunit.xml file in Netbeans.

    "C:\xampp\php\php.exe" "C:\xampp\php\phpunit" "--colors" "--log-junit" "C:\Users\xxx\AppData\Local\Temp\nb-phpunit-log.xml" "--configuration" "C:\xampp\htdocs\yyy\phpunit.xml" "C:\Program Files\NetBeans 8.0.1\php\phpunit\NetBeansSuite.php" "--run=C:\xampp\htdocs\yyy\tests"
    PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

推荐答案

这是2011年的Netbeans错误.他们说:这是大多数用户的预期行为."

This is Netbeans bug from 2011., they say "This is the expected behavior, I would say, for most of the users.".

这是参数--run=C:\xampp\htdocs\yyy\tests.

如果有人对此进行了解决,请分享.

If someone made workaround around this please share.

为什么Netbean从XML配置中忽略PHPUnit测试包? /a>

Why Netbean ignore PHPUnit testsuite from the XML config?

https://netbeans.org/bugzilla/show_bug.cgi?id=199072

这篇关于忽略/忽略phpunit.xml中的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:59
查看更多