views:

100

answers:

2

Is there a way, a method, to be able to effectively run unit tests (phpunit) on both linux and windows?

I need to do this because some parts of the system is only available under linux, but i do want to be able to run certain parts of the test suite in my IDE, which is netbeans by the way.

The problems i run into have to do with paths most of the time. To complicate things more i also intend to run the tests from within phing.

But the thing i haven't adressed yet is the ability to tailor different testsuites for different platforms. Is this even possible?

Tests are basically living inside the test directory and source is within src. The includepaths are handled by an included file. Would it be possible to use an autoloader to handle different directory structure?

+1  A: 

I don't really see your problem. Use PATH_SEPARATOR, check for the OS using PHP_OS, also use phpunit.xml

You can also create two(or more) PHPUnit XML configuration files if you need them.

Marius Burz
Well, now that i know, i don't see the problem either. But the combination of these was not really that obvious to me.
Peter Lindqvist
Glad it worked out. We are hear to learn, so take it easy :)
Marius Burz
+2  A: 

To complicate things more I also intend to run the tests from within phing.

To run specific parts of your phing work-flow per operating system, you can use the ConditionTask.

http://phing.info/docs/guide/stable/chapters/appendixes/AppendixB-CoreTasks.html#ConditionTask

Is there a way, a method, to be able to effectively run unit tests (phpunit) on both Linux and windows?

you can annotate your PHPUnit tests with:

@group

This allows you to specify a particular "group" of tests to run. So, for all tests that pertain to windows, you could tag them as:

@group oswin

Then when you run phpunit you specify the "oswin" group. For example:

phpunit --group oswin

wilmoore