2013-09-26 30 views
4

我已經爲我的應用程序模塊和其他模塊進行了測試。他們工作正常,但我想運行所有的測試(應用程序模塊和其他模塊)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是如何將其納入同一系統啓動時進行各項測試,以避免例外。

回答

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> 

然後你就可以用運行:/路徑/到/ PHPUnit的--testsuite = 「ALL」

+1

有一種方法可以爲每個模塊設置引導程序? – Dann

+0

@ user1835922:是通過指定引導文件與不在XML文件內的testrunner。 – hakre

相關問題