01.01.2021

Maven Install Skip Unit Tests With Phpunit

Maven Install Skip Unit Tests With Phpunit 6,0/10 6282 votes
Active2 months ago

Maven Install Skip Unit Tests With Phpunities

Modify the Maven.php file as described above and run a 'mvn install' from the /src dir - this will install the modified maven for php plugin locally and you will be able to work with it. Share improve this answer. How to skip maven unit test in Eclipse. Install, clean maven. You have to run all the unit tests. The problem is when you have plenty of tests or database connections to test, the time that the build need is way too long. It is possible to build without running the tests. An example of a maven build goal to skip tests is: clean. Skip Test case execution in maven doesn't even compile Test cases. Mvn clean install -Dmaven.test.skip=true The Skip test doesn't even compile the unit test source. How do you build a Maven project without running unit tests? Mvn -Dmaven.test.skip=true install. You can also use the maven.test.skip property to skip.

I am using phpunit in connection with jenkins, and I want to skip certain tests by setting the configuration in the XML file phpunit.xml

I know that I can use on the command line:

phpunit --filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest

how do I translate that to the XML file since the <filters> tag is only for code-coverage?

I would like to run all tests apart from testStuffThatAlwaysBreaks

Ben Creasy
2,1432 gold badges21 silver badges39 bronze badges
FilypeFilype
5,2327 gold badges32 silver badges56 bronze badges

3 Answers

The fastest and easiest way to skip tests that are either broken or you need to continue working on later is to just add the following to the top of your individual unit test:

Daniel W.
20.8k7 gold badges52 silver badges100 bronze badges
jsteinmannjsteinmann
2,3642 gold badges13 silver badges19 bronze badges
zerkmszerkms
198k50 gold badges359 silver badges451 bronze badges

Sometimes it's useful to skip all tests from particular file based on custom condition(s) defined as php code. You can easily do that using setUp function in which makeTestSkipped works as well.

your_custom_condition can be passed via some static class method/property, a constant defined in phpunit bootstrap file or even a global variable.

Konrad GałęzowskiKonrad Gałęzowski

Not the answer you're looking for? Browse other questions tagged phpphpunit or ask your own question.

Active6 years, 8 months ago

I want to use Maven for PHP with PHPUnit but when I run my tests with 'mvn test' I get this error: http://pastie.org/948377

This happens only when I use a version newer than 3.3.9 for PHPUnit. The tests work just fine with PHPUnit 3.3.9.

hakre
164k33 gold badges323 silver badges637 bronze badges
SoftySofty

1 Answer

I found the problem, it is in Maven.php file from the maven for php plugin.

Maven Skip Unit Test

On line 26 you have:

$arguments['xmlLogfile']=$targetFile;

For PHPUnit versions newer than 3.3. Hp 1702 drivers. 9 you should have Dell xps 13 9350 user manual.

$arguments['junitLogfile']=$targetFile;

The name of 'xmlLogFile' argument changed to 'junitLogFile' from version 3.4.0 on.

I hope the maven for php guys will make the correction asap.Until then you have to checkout the plugin source from here: http://svn.key-tec.de/php-maven/tags/multimaster-1_0/org.phpmaven.multimaster/org.phpmaven.plugin

Skip Tests In Maven Build

Modify the Maven.php file as described above and run a 'mvn install' from the /src dir - this will install the modified maven for php plugin locally and you will be able to work with it.

Maven Skip Unit Tests

SoftySofty

Maven Install Skip Unit Tests With Phpunit Documentation

Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Maven Install Skip Unit Tests With Phpunit Tutorial

Not the answer you're looking for? Browse other questions tagged phpphpunitmaven-for-php or ask your own question.