如何在我的应用程序中测试每个模块phpunit - zend framework 2

问题描述:

我已经为我的应用程序模块和其他模块进行了测试。他们工作正常,但我想运行所有的测试(应用程序模块和其他模块)toguether生成jenkins的三叶草报告。我该怎么办??创建另一个配置文件来调用其他配置文件?如何在我的应用程序中测试每个模块phpunit - zend framework 2

---编辑---

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

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

应用程序模块的测试工作正常,但在测试问题模块不会在命名空间声明工作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; 

的问题,我有分辩现在运行所有测试toguether是如何将其纳入同一系统启动时进行各项测试,以避免例外。

我不能发表评论但是如果您不想独立命名每个模块,可以在zend framework 2 + phpunit + multiple modules + continuous integration处找到有关此问题的另一个解决方案。

您可以制作测试套件,以便一次运行一组单个测试。在您的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> 

然后你就可以用运行:/路径/到/ PHPUnit的--testsuite = “ALL”

+1

有一种方法可以为每个模块设置引导程序? – Dann

+0

@ user1835922:是通过指定引导文件与不在XML文件内的testrunner。 – hakre