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

I have already done a test for my application module and another module. They work fine, but I want to run the whole test (application module and another module) to create a bite report for jenkins. What should I do?? create another configuration file to call other configuration files.

--- edit ---

I have the same code for each bootstrap.php module, and I want to use it for each module to avoid code duplication. 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 the problems module does not work for declaring the namespace in the phpunit_bootstrap.php file.

My Application Test uses this declaration:

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

My Problem tes uses this ad:

 <?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 am currently facing in order to run the entire test method is how to include the same boot file for each test in order to avoid this exception.

+4
source share
2 answers

I can’t comment, so another solution to this problem can be found in zend framework 2 + phpunit + several modules + continuous integration If you do not want to name each module independently.

+1
source

You can make testuite to run multiple test groups at once. In the 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"

+3
source

All Articles