【发布时间】:2014-04-29 21:16:30
【问题描述】:
我无处找到解决方案,有不同的方法可以做到这一点,但我只想知道我是否可以这样做:
Project
| - config
| - data
| - module
| | - Application
| | | - config
| | | - src
| | | - test <---------------------unit test for each module
| | | | - ApplicationTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist
| | | - view
| | | - Module.php
| | - Album
| | | - config
| | | - src
| | | - test
| | | | - AlbumTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist
| | | - view
| | | - Module.php
| - public
| - vendor
| - tests <------------------centralize launch of all tests for reporting on Jenkins
| build.xml <----------------This file launch phpunit.xml in ./tests/phpunit.xml
在根目录的测试目录中,我想放置一个 xml 用于启动每个模块的每个单元测试,并为 Jenkins 制作一个报告文件。 我看了很多教程,包括:
或者stackoverflow中的问题很有趣,但不是我想要的:
zf2 + phpunit + multiple module + CI
在堆栈上,有这个问题,但我试过了,但没有用:
Zend Framework 2 Unit Tests on Jenkins not working
感谢您的帮助
编辑[03/24/2014 - 12:25] :我终于找到了一种方法,就是将 Bootstrap.php、TestConfig.php 放在测试目录中。
Project
| - config
| - data
| - module
| | - moduleName1
| | | - config
| | | - src
| | | - test <---------------------unit test for each module
| | | | - ApplicationTest
| | | - view
| | | - Module.php
| | - moduleName2
| | | - config
| | | - src
| | | - test
| | | | - moduleName2Test
| | | - view
| | | - Module.php
| - public
| - vendor
| - tests
| | -phpunit.xml <-------- Jenkins fail here
| | -Bootstrap.php
| | -TestConfig.php
| build.xml <----------------This file launch phpunit.xml in ./tests/phpunit.xml
我的 phpunit.xml 代码如下:
<phpunit bootstrap="Bootstrap.php" colors="true"
stopOnError="true"
stopOnFailure="false"
strict="true"
verbose="true">
<testsuites>
<testsuite name="All">
<directory>../module/moduleName1/test/moduleName1Test</directory>
<directory>../module/moduleName2/test/moduleName2Test</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="../build/coverage/" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="../build/logs/clover.xml"/>
<log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
并且,在行命令中,报告文件被正确生成,我的断言很好,一切正常。
但是,有一件小事让我抓狂!!!我找不到我必须在 build.xml 上写什么命令才能使用 jenkins 启动 phpunit.xml 我尝试了很多东西,jenkins 一直在说:
Total tests run: 0, Failures: 0, Errors: 0, Incomplete: 0, Skipped: 0, Time elapsed: 0.00100 s
我确定我的 phpunit.xml 已加载,但它根本无法工作...有什么想法吗?
【问题讨论】:
标签: xml unit-testing jenkins zend-framework2 phpunit