Home » Php » unit testing – Cruise Control and PHP projects

unit testing – Cruise Control and PHP projects

Posted by: admin July 12, 2020 Leave a comment

Questions:

I’m looking for a complete solution to a automated “building” and testing of PHP application. I came across PhpUnderControl, a solution for running automated application builds created around Cruise Control.

Unfortunately PhpUC is still in it’s early stages of development and I can’t get it to work on windows box.

After few hours of trying I gave up on phpUc. I’m now trying to use Cruise Control alone. It works just fine when it comes to running whole build process. Every command I put into ant’s build file runs ok.

The only problem I’ve got is that Cruise Control won’t merge logs from run builds into project log file, therefore I’m not able to see any build results. But the sample project in Cruise control works ok, logs for builds are merged into project’s log.

I’m wondering if Cruise Control is able to merge logs created by PHPUnit (in XML format) into project log or is it working for Java’s JUnit files only. Has anyone tried to use Cruise Control alone on a php project?

here’s the log section of project’s configuration (config.xml):

<log dir="logs/${project.name}">
<merge dir="projects/${project.name}/build/logs/"/>
</log>

This is copy-pasted + paths changed from Cruise Control’s sample project.

Any thoughts anyone please.

Thanks

How to&Answers:

I’m wondering if Cruise Control is
able to merge logs created by PHPUnit
(in XML format) into project log or is
it working for Java’s JUnit files
only.

CC will merge any xml file you point it at. When you say merging the files isn’t working are you getting an error merging them or are the test results not showing up on the results page? If you look at the build log file do you see the test results merged in?

One issue you might be seeing is that the .xsl files in the jsp reporting application are expecting the test results to be in the structure that the ant junit task creates. What might be happening is that you’re merging in the files but the .xsl doesn’t know how to display the results.

But I think there’s a simple solution. The PhpUnderControl project supplies a phpunit.jsp. I think if you add this to your existing CC install you’ll be able to view the test results. You can add the phpunit.jsp to the tabs pretty easily; just look at main.jsp and it should be obvious.

If you have any follow-up questions I recommend the CruiseControl users mailing list.

(I haven’t used CC on a PHP project but I’m one of the CC committers.)

Answer:

phpunit, phpUnderControl and CC work great!

For getting the tests in the tab (phpUnderControl with CC) in the phpunit xml file ensure that the phpunit log file generated is in the correct path

  <log type="junit" target="...../cruisecontrol-bin-2.8.4/projects/<projname>/build/logs/logfile.xml" logIncompleteSkipped="false"/>

Once the logfile.xml is generated from phpunit tests are shown in the tests tab of both phpUnderControl and CC.

Answer:

I have found that CruiseControl only merge the logs containing test results when a test fails.

When I broke a test on purpose, the results got merged into the log, and where shown on the CruiseControl dashboard.

Could that be your problem?

Answer:

We tried using PHPUc with CC and we couldn’t get the stuff to work right. We experimented with straight CC but found it difficult to get authentication in there (we’re distributed, so our reports would be open to the world unless we nailed it down–we couldn’t figure it out.)

So, we’re now actually using Hudson as our CI engine and Phing as our build tool. It works just fine. We have code coverage reports coming straight out of PHPUnit (which Hudson still calls “Clover coverage” from the Java world, but hey it’s just a name of a link and we know what it means).

Hudson was easy to set up and seems to work with everything you’d need for PHP.