4

我已经对我的应用程序模块和其他模块进行了测试。他们工作正常,但我想同时运行所有测试(应用程序模块和其他模块)以为詹金斯生成三叶草报告。我应该怎么办??创建另一个配置文件来调用其他配置文件??

- -编辑 - -

我对每个模块 bootstrap.php 都有相同的代码,我想对每个模块使用相同的代码以避免代码重复。现在我有两个模块应用程序和问题,当我运行 phpunit 时,它会抛出这个错误:

**.PHP Fatal error:  Class 'ProblemTest\Bootstrap' not found ....**

Application 模块的测试工作正常,但 Problem 模块的测试不适用于phpunit_bootstrap.php文件中的命名空间声明。

我的应用程序测试使用此声明:

<?php
   namespace ApplicationTest\Controller;
   use ApplicationTest\Bootstrap; ....

我的问题 tes 使用这个声明:

<?php
    namespace ProblemTest\Controller;
    use ProblemTest\Bootstrap;

这是我的 phpunit.xml

<phpunit bootstrap="phpunit_bootstrap.php">
<testsuites>
    <testsuite name="ALL">
        <directory>module/Application/test</directory>
        <directory>module/Problem/test</directory>
    </testsuite>
</testsuites>

这是我的 phpunit_bootstrap.php

<?php
 namespace ApplicationTest;

我现在可以一起运行所有测试的问题是如何为每个测试包含相同的引导程序以避免该异常。

4

2 回答 2

3

您可以制作一个测试套件来一次运行一组单独的测试组。在您的 phpunit.xml.dist 文件中:

<phpunit bootstrap="phpunit_bootstrap.php">
    <testsuites>
        <testsuite name="all">
            <directory>./</directory>
        </testsuite>
        <testsuite name="ALL">
            <directory>/path/to/module1tests</directory>
            <directory>/path/to/module2tests</directory>
            <directory>/path/to/module3tests</directory>
            <exclude>/path/to/module4tests</exclude>
        </testsuite>
        <testsuite name="module1only">
            <directory>./module1tests</directory>
        </testsuite>
    </testsuites>

然后你可以运行它: /path/to/phpunit --testsuite="ALL"

于 2013-09-26T14:37:20.140 回答
1

我无法发表评论,所以如果您不想单独命名每个模块,可以在zend 框架 2 + phpunit + 多个模块 + 持续集成中找到另一个解决方案。

于 2014-08-05T06:00:32.880 回答