views:

213

answers:

2

When running the "mvn test" command, the PHPUnit tests are run. The problem I have is that the setUpBeforeClass() method within a test class is not called when running the tests from maven. Does anybody know the problem? I use the last version of PHPUnit (3.3.9) available on repositories.

A: 

If i understand the docs of phpunit correct there is no setUpBeforeClass() for the 3.3.9 release only in PHPUnit 3.4.X Release i found such method.

khmarbaise
Thank you. Then is there any method to use the PHPUnit 3.4.X with Maven for PHP? Any ideas? I tried to manually install a zip/jar file in the local repository as they say on the http://www.php-maven.org/add3partylibs.html but it seems not to work...
Softy
What does not work? Error Message?
khmarbaise
It seems that maven sees the PHPUnit 3.4.12 version, runs it, but I get an error. at org.phpmaven.plugin.build.PhpUnitCompile.executePhpFile(PhpUnitCompile.java:241) ... 28 more[DEBUG] --- Compiling has finished.[INFO] ------------------------------------------------------------------------[ERROR] BUILD ERRORCaused by: org.phpmaven.plugin.build.PhpCompileException:ANDCaused by: org.apache.maven.plugin.MojoExecutionException:
Softy
A: 

As mentioned by @khmarbaise, support of setUpBeforeClass() has been added in PHPUnit 3.4+ (see Ticket #814) and my understanding is that you would just have to install PHPUnit 3.4+ from PEAR to get it used by Maven. Follow the install instructions.

Pascal Thivent
Thank you, Pascal. The problem is I can't get the 3.4.12 (the last version) working with maven. I tried to manually install a zip/jar file in the local repository as they say on the php-maven.org/add3partylibs.html but it seems not to work.When running "mvn install" it gives me a build error wothout any description.[INFO] php.out: PHPUnit 3.4.12 by Sebastian Bergmann.[INFO] php.out: Time: 1 second, Memory: 4.25Mb[INFO] php.out: OK (2 tests, 2 assertions)[ERROR] Testcase: querytest.php fails.[ERROR] See log: C:\un/querytest.txt[INFO]PHPUnit 3.4.12 by Sebastian Bergmann...Any ideas?
Softy
querytest.txt content:PHPUnit 3.4.12 by Sebastian Bergmann...Time: 1 second, Memory: 4.25MbOK (2 tests, 2 assertions)
Softy
@Softy I may be wrong but I don't thing that adding PHPUnit to your local repository does change something. I understood that phpunit is an executable, installing a newer version from PEAR will make you use the newer version. Does your current version of phpunit work outside Maven? Can you test this?
Pascal Thivent
@Pascal I do have the last version (3.4.12) in place and working, I used it to test my tests before trying it with maven. So it is installed on my system. But if I don't put a dependency in the pom.xml to the phpunit it doesn't see it.
Softy
@Softy Ok, forget what I said then. So to summarize: phpunit 3.4.12 works on the command line, you can run your test with it, but it doesn't work under Maven. Is that correct? Can you try to call `mvn -X -e` to see if you get more information about the problem?
Pascal Thivent
I get something like this: (extract from huge output) - is there any way I can send you the whole output?org.apache.maven.plugin.MojoExecutionException:PHPUnit 3.4.12 by Sebastian Bergmann...Time: 1 second, Memory: 4.25MbOK (2 tests, 2 assertions) in at org.phpmaven.plugin.build.PhpUnitCompile.executePhpFile(PhpUnitCompile.java:251)......... at org.codehaus.classworlds.Launcher.main(Launcher.java:375)Caused by: org.phpmaven.plugin.build.PhpCompileException:
Softy
@Softy post the output on a paster like http://pastie.org and put the link here as comment.
Pascal Thivent
@Pascal Thank you! I've tried several other versions of PHPUnit (3.4.0/3.4.2/3.4.10) and I put here the error: http://pastie.org/948377 (3.4.0). Hope you can see something in there.
Softy
Can anybody help? Please?
Softy