简体   繁体   中英

How to test every module in my application phpunit - zend framework 2

I already made test for my application module and other module. They are working fine but i want to run all the test (application module and other module) toguether to generate clover report for jenkins. What should i do?? create another config file to invoke other config files??

---edit---

I have the same code for each module bootstrap.php and i want to use the same for each module to avoid code duplication. Rigth now i have two modules Application and Problem when i run phpunit it throws me this error:

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

The test for the Application module works fine but the test for Problem module doesn't work for the namespace declaration in the phpunit_bootstrap.php file.

My Application test uses this declaration:

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

My Problem tes uses this declaration:

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

This is my phpunit.xml

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

this is my phpunit_bootstrap.php

<?php
 namespace ApplicationTest;

The problem that i have rigth now to run all the test toguether is how to include the same bootstrap for every test to avoid that exception.

You can make a testsuite to run a bunch of individual groups of tests all at once. In your phpunit.xml.dist file:

<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>

And then you can run it with: /path/to/phpunit --testsuite="ALL"

我还不能发表评论所以可以在zend框架2 + phpunit +多个模块+持续集成中找到这个问题的另一个解决方案如果你不想单独命名每个模块。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM