PHPSpec - 无法运行,有人使用它进行 php 开发吗?

发布于 2024-07-09 15:30:45 字数 558 浏览 3 评论 0原文

搜索了 stackoverflow 并没有找到答案

来自 Ruby On Rails 和 Rspec,我需要像 rspec 这样的工具(更容易过渡)。 通过 PEAR 安装它并尝试运行它,但它还不起作用

只是想问问周围是否有人使用它有同样的问题,因为它根本没有运行

尝试使用手册中的示例运行它 - http://dev.phpspec.org/manual /en/before.writing.code.specify.its.required.behaviour.html

phpspec NewFileSystemLoggerSpec

返回

即使运行也不

phpspec some_dummy_value

任何内容

Searched stackoverflow for this and found no answer

Coming from Ruby On Rails and Rspec, I need a tool like rspec (easier transition). Installed it through PEAR and tried to run it but it's not working (yet)

Just wanna ask around if anyone's using it have the same problem, since it's not running at all

tried running it with an example from the manual - http://dev.phpspec.org/manual/en/before.writing.code.specify.its.required.behaviour.html

phpspec NewFileSystemLoggerSpec

returns nothing

even running

phpspec some_dummy_value

returns nothing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

眼中杀气 2024-07-16 15:30:45

PHPSpec 的开发在中断 2 年之后于 2010 年 8 月重新开始。 代码库现在看起来更加稳定。 我会再尝试一次。

该网站现在位于 www.phpspec.net

您可以在 http://www.phpspec.net/ 找到文档文档。 它基本上是第一个版本的更新。

如果您需要任何进一步的帮助,您还可以通过他们的邮件列表联系开发人员:
http://groups.google.com/group/phpspec-dev

Development on PHPSpec has restarted since August 2010, after a 2 years break. The code base looks more stable now. I would give another try.

The website is now located at www.phpspec.net

You can find the documentation at http://www.phpspec.net/documentation. It is basically an update of the first version.

Should you require any further assistance you can also reach the developers through their mailing list:
http://groups.google.com/group/phpspec-dev

享受孤独 2024-07-16 15:30:45

我也无法让它运行,但您也可以将 BDD 与 PHPUnit 结合使用。 查看文档

I also couldn't get it to run, but you can also use BDD with PHPUnit. Check the documentation:

夜夜流光相皎洁 2024-07-16 15:30:45

真的很期待使用 PHPSpec,哦我想会检查 PHPUnit

Was really looking forward to using PHPSpec, oh I guess will check into PHPUnit

帥小哥 2024-07-16 15:30:45

我尝试使用 phpspec 但发现它太多错误/不成熟。 我强烈推荐 SimpleTest 来编写单元测试。

I tried using phpspec but found it too buggy/immature. I can highly recommend SimpleTest for writing unittests.

一杯敬自由 2024-07-16 15:30:45

您可以在 PHPUnit 中编写 RSpec 类型的测试,但它受到一些因素的阻碍。

  • PHPUnit 模拟不允许你
    重新声明它们,因此很难设置
    之前的一堆存根
    方法,然后将它们重写为
    需要。 您可以通过以下方式解决此问题
    安排存根的设置
    超出了预期,但这很奇怪。

  • PHP 不像 Ruby 那样动态,所以你
    不能轻易模拟或存根类
    方法除非你特别
    为此设计课程,甚至
    那么它就很难看了。 (这可能
    随着 PHP 5.3 的后期静态变化
    绑定功能)。

You can write RSpec-ish types of tests in PHPUnit, but it's hindered by a couple of things.

  • PHPUnit mocks don't let you
    re-declare them so it's hard to set
    up a bunch of stubs in a before
    method and then override them as
    needed. You can work around this by
    arranging for the stubs to be setup
    after the expectations, but it's odd.

  • PHP isn't as dynamic as Ruby so you
    can't easily mock or stub out class
    methods unless you specifically
    design the class for this and even
    then it's pretty ugly. (This may
    change with PHP 5.3's late static
    binding features).

坏尐絯℡ 2024-07-16 15:30:45

我已经成功使用了 PHPSpec,但现在它还没有积极开发,是吗? 这很棒,但我不认为我会接受一个停滞的项目。 无论如何,我使用以下设置从网络浏览器运行测试,也许您会找到一些东西来帮助您为 CLI 设置它。

PHPSpecConfiguration.php

$projectDir = realpath( dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' ) . DIRECTORY_SEPARATOR;

$simdal_root = $projectDir . 'library';
$phpspec_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'PHPSpec';
$mockery_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'Mockery';

$paths = array(
    'SimDAL'=>$simdal_root,
    'PHPSpec'=>$phpspec_root,
    'Mockery'=>$mockery_root
);

set_include_path( implode( PATH_SEPARATOR, $paths ) . PATH_SEPARATOR . get_include_path() );

require_once 'PHPSpec.php';
require_once 'Mockery/Framework.php';

class Custom_Autoload
{
    public static function autoload($class)
    {
        //$path = dirname(dirname(__FILE__));
        //include $path . '/' . str_replace('_', '/', $class) . '.php';
        if (preg_match('/^([^ _]*)?(_[^ _]*)*$/', $class, $matches)) {
            include str_replace('_', '/', $class) . '.php';
            return true;
        }

        return false;
    }

}

spl_autoload_register(array('Custom_Autoload', 'autoload'));

以及运行它的文件:AllSpecs.php;

require_once 'PHPSpecTestConfiguration.php';

$options = new stdClass();
$options->recursive = true;
$options->specdocs = true;
$options->reporter = 'html';

PHPSpec_Runner::run($options);

我不喜欢 CLI 测试...但这可能对某人有帮助。

I have used PHPSpec succesfully but it's not actively developed now is it? It's great but don't think I would go with a stalled project. Anyway to the point I used the following setup to run the tests from the webbrowser, maybe you'll find something to help you to set it up for CLI.

PHPSpecConfiguration.php

$projectDir = realpath( dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' ) . DIRECTORY_SEPARATOR;

$simdal_root = $projectDir . 'library';
$phpspec_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'PHPSpec';
$mockery_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'Mockery';

$paths = array(
    'SimDAL'=>$simdal_root,
    'PHPSpec'=>$phpspec_root,
    'Mockery'=>$mockery_root
);

set_include_path( implode( PATH_SEPARATOR, $paths ) . PATH_SEPARATOR . get_include_path() );

require_once 'PHPSpec.php';
require_once 'Mockery/Framework.php';

class Custom_Autoload
{
    public static function autoload($class)
    {
        //$path = dirname(dirname(__FILE__));
        //include $path . '/' . str_replace('_', '/', $class) . '.php';
        if (preg_match('/^([^ _]*)?(_[^ _]*)*$/', $class, $matches)) {
            include str_replace('_', '/', $class) . '.php';
            return true;
        }

        return false;
    }

}

spl_autoload_register(array('Custom_Autoload', 'autoload'));

and then the file that runs it all: AllSpecs.php;

require_once 'PHPSpecTestConfiguration.php';

$options = new stdClass();
$options->recursive = true;
$options->specdocs = true;
$options->reporter = 'html';

PHPSpec_Runner::run($options);

I don't like CLI testing...But this might help someone.

画尸师 2024-07-16 15:30:45

你好,它确实是一个相当老的问题,但我认为 http://behat.org/ 应该在这里。 每个人都有这个问题,应该检查一下。

Hello its pretty old Q. in deed, but i think http://behat.org/ should be here. Everyone has this problem should check it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文