Taming the MXUnit Ecplise Plugin with Apache Alias

If you are into Unit Testing and haven't yet heard of MXUnit, I definitely recommend giving it a whirl. Some things that stand out for me, thus far in my evaluation, are the simple, but extensible, assertions, the ecplise plugin, and the debug output. One gotcha that has come up for people when using the eclipse plugin, is that is was designed assuming that the package path to your components resolves directly from your web root. For people who run separate server instances, virtual machines, or develop locally with Apache virtual hosts, this is a show stopper. Luckily, for folks, like myself, who prefer to develop locally with Apache, getting the MXUnit eclipse plugin to work is simply a matter of adding a couple of Alias directives to your vhost.

[More]

Comments
marc esher's Gravatar Hey Paul, can you explain why the "component root" setting didn't work for you here?

thanks!
# Posted By marc esher | 3/9/08 7:08 AM
Paul Marcotte's Gravatar Hi Marc,

I tried using the component root as a path to my tests folder, but I could not get it to resolve correctly. This is probably because the proper path to my tests should be "tests", not "myproject.root.tests".

Cheers,

Paul
# Posted By Paul Marcotte | 3/9/08 1:26 PM
marc esher's Gravatar for your "myproject/root"... is this project just a project for holding tests? i.e. is the contents of that project just test cases (and other stuff). i'm having trouble visualizing this whole thing.

because if it is just a project for tests (that's what I do at work, by the way), then i'm wondering why you couldn't set up the project in eclipse like this:

project home = /users.../myproject/root/
component root = "tests".

so if there's a file /users.../myproject/root/MyTest.cfc

then it would resolve to tests.MyTest

Or is that not how the file system is set up?

Thanks a lot for going through all this Paul. It's either going to result in A) better documentation on our end on how to do this stuff or B) better support in the plugin for your kind of set up.

marc
# Posted By marc esher | 3/9/08 2:18 PM
Paul Marcotte's Gravatar Hi Marc,

Nope. /Users/../myproject/root is the path to a web root. In that web root, I have a folder for model cfcs, and a folder for tests. For the web site in question, I don't use a class path myproject.root.model.ClassName, I use model.ClassName. And in the tests folder, I use the suffix "Test" for each test case for a given cfc, so it mirrors the model as in tests.ClassNameTest.

Since the plugin expects that the class path should start with "myproject" and follow to the root folder using the Alias "/myproject/root" allows the plugin to resolve to the correct root path which should actually just be "/".

I hope that makes a little more sense. It's probably a bit confusing that I keep my vhost sites under my web root, I should get into the habit of keeping them in a different location.
# Posted By Paul Marcotte | 3/9/08 7:28 PM
marc esher's Gravatar I think I got it now.

so really, to make this as flexible as it needs to be, it sounds like it'd be nice to be able to select any directory, say a directory named "tests", and specify the component path on that directory. so if you had a directory named "tests", and all components under it would have their path start with "tests", like "tests.business.MyBusinessTest", then conceivably you'd right click on that "tests" directory, get a little popup, and enter "tests". and from then on, components in that directory and subdirectories would use that as their starting point and not the "properties -- component root" or "preferences -- webroot" settings.

Does that sound about right?
# Posted By marc esher | 3/9/08 8:05 PM
Paul Marcotte's Gravatar That sounds right to me, so long as object instantiation within the tests would resolve similarly as in "model.business.MyBusiness".

Cheers!
# Posted By Paul Marcotte | 3/10/08 12:08 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner