MXUnit running with sub-foldered project

105 views
Skip to first unread message

James Buckingham

unread,
Oct 4, 2010, 6:02:39 AM10/4/10
to mxunit
Hi everyone,

We've having a bit of a headache getting MXUnit installed for our new
project and I was wondering if I could get some help please?

What we've got is a new project ( for namesake I'll call it project
2 ) & we're newly introducing Unit Testing as part of this. This
project is going to be sitting off a URL from our website (project1)
but directory structure-wise we're keeping it all separate.

Just to clarify the address on my laptop just now is:-

http://localhost/project2

... with project2 being an IIS virtual directory

Directory structure I have is this.....

- wwwroot
-- Project1
-- Project2
--- mxunit

Project 2 is a ColdBox 3.0 app.

I'm trying to set all this up so MXUnit is sitting in the root of
Project2 and although I'm getting a browser result from it my tests
are failing with messages like this :-

"The .integration.GeneralTest name is not a valid component or
interface name."

Note the . at the start of the CFC address.

Address is running from http://localhost/project2/test/TestSuite.cfm

I've plugged up MXUnit, ColdBox and Transfer in my Application.cfc of
the "test" folder, MXUnit is referenced like so....

<cfset this.mappings['mxunit'] = expandPath('../../common/MXUnit/
v2.0.0 (vendor)') />

We've been asking about this on the Coldbox groups as well, and
haven't really very far, so I hope some might be able to help here
instead :-)

Cheers,
James

Marc Esher

unread,
Oct 4, 2010, 6:51:10 AM10/4/10
to mxu...@googlegroups.com
Hey James,
Is that error you're getting when you run it from the Eclipse
plugin? Or do you get that error whenever you run a test directly in
the browser?

Also, for project 2, how does coldfusion see those components; for
example, is it project2.tests.integration.GeneralTest ?

thanks.

Marc

> --
> You received this message because you are subscribed to the Google Groups "mxunit" group.
> To post to this group, send email to mxu...@googlegroups.com.
> To unsubscribe from this group, send email to mxunit+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mxunit?hl=en.
>
>

James Buckingham

unread,
Oct 4, 2010, 7:11:12 AM10/4/10
to mxunit
Hey Marc,

Good to hear from you.

I'm trying the Eclipse plugin at the moment but the errors above I'm
seeing in a browser.

CF - Like I say it's ColdBox (3.0.0 M6) so it should be going from the
application root into test.integration. However there is an
Application.cfc in the test folder so I'm assuming this is meant to
run in isolation (as you'd expected I guess!)

If it were from CB root then it's missing the "test" prefix. The CB UG
seem to recommend I run MXUnit from the web root, but that's going to
lead to other complications for us as we've our website running from
there.

---

If it helps.....

MXUnit I've got setup as a mapping in the CFAdmin pointing at a folder
external to the projects .....

C:/inetpub/common/MXUnit/v2.0.0 (vendor)/

But I've also tried dropping it in the CB root and running it from
there, neither seems to give me a success result.

Thanks again,
James

James Buckingham

unread,
Oct 4, 2010, 7:52:28 AM10/4/10
to mxunit
Ok think I've got this up and running, got passing tests in both
browser and Eclipse, but if you don't mind I just want to check and
see if there is a better way of doing this before I move on...

In my "test" Application.cfc I've added some absolute addresses to a
number of places.... namely :-

<cfset this.mappings['/'] = 'C:\Inetpub\EnrolNow\www\' />
<cfset this.mappings['/config'] = 'C:\Inetpub\EnrolNow\www\config' /
>
<cfset this.mappings['/coldbox'] = 'C:\Inetpub\common\ColdBox\v3.0.0
M6 (vendor)\' />
<cfset this.mappings['/test'] = 'C:\Inetpub\EnrolNow\www\test' />
<cfset this.mappings['/mxunit'] = 'C:\Inetpub\common\MXUnit\v2.0.0
(vendor)' />
<cfset this.mappings['/transfer'] = 'C:\Inetpub\common\Transfer\v1.1
(vendor)' />

I'll tidy these up soon but just to say, that for some reason, MXUnit
didn't like the fact that my ColdBox configuration has a /config on
the path of my Transfer XML config file. I need that though otherwise
Transfer grumbles at me. Can anyone think of a cleaner way of doing
this so I don't need a mapping for everytime I have a "/" style
address? Preferably I'd like something off the back of the / mapping

CB related but - in the Unit Tests that came with ColdBox I had to
remove the appMapping attributes in the cfcomponent otherwise it was
trying to load things in from the demo files not my project.

----

In Eclipse I had to do the following in the MXUnit Properties of the
project .....

Test Runner URL - http://localhost/project2/test/resources/RemoteFacade.cfc
cfc path: /

Again this was so the Facade was loaded in through the test
application and without the / in the cfc path MXUnit was trying to
load the tests up through www.test/ The / is a reference to the
mappings I've put in the Application.cfc.

All this seems to be working but if anyone has any suggestions on
improvement I'm all ears :-).

Cheers,
James

James Buckingham

unread,
Oct 4, 2010, 9:21:19 AM10/4/10
to mxunit
Actually not quite there :-)

I noticed in the browser version a few things weren't quite right....

- It looks like there is a variable called pathBase. If I drop a copy
of MXUnit in the project root then the framework assigns the value /
mxunit to it. That's great because I've got a mapping in IIS so all
the graphics etc. display perfectly.

One of my colleagues tried to run this though, with MXUnit external to
the project, and it broken. Reason being the the value of pathBase was
equal to /common.MXUnit 2.0.0.0 (vendor), which isn't valid.

Is there anyway we can configure pathBase ourselves to always use a
mapping?

---

The 2nd thing was that though the tests are passing it's throwing a
404 when I click on any of the test titles / links. Reason seems to be
that it's trying to launch them as:

http://localhost/test/integration/MainTest.cfc?method=......

Rather than....

http://localhost/project2/test/integration/MainTest.cfc?method....

Again is there anyway of configuring these to read from the correct
base?

Thanks once again,
James

Marc Esher

unread,
Oct 4, 2010, 11:23:40 AM10/4/10
to mxu...@googlegroups.com
is the "pathBase" variable in mxunit/runner/index.cfm?

James Buckingham

unread,
Oct 4, 2010, 2:25:33 PM10/4/10
to mxunit
Hi Marc,

Yeap found it in there but the solution we came up with was to change
this line in the mxunit-config.xml from false to true

<config-element type="userConfig" name="componentRoot" value="mxunit"
override="false" />

Also, for the 2nd part, my boss put the following change into
HTMLTestResult.cfc - line 172:

From - <cfset classtesturl = "/" &
Replace(this.testResults[i].component, ".", "/", "all") & ".cfc?
method=runtestremote&amp;output=html">

To - <cfset classtesturl = "/project2/" &
Replace(this.testResults[i].component, ".", "/", "all") & ".cfc?
method=runtestremote&amp;output=html">

That seems to have done the job but of course it's meant forking the
version of MXUnit we've got here :-(.

Is there anyway that the classtesturl prefix could be configured
somewhere outside the MXUnit core? Maybe the config XML? Would also be
good if we could drop the xml config in our project and configure from
there..... but maybe I'm asking a lot :-)

Cheers,
James

Marc Esher

unread,
Oct 5, 2010, 5:56:42 PM10/5/10
to mxu...@googlegroups.com
James,

Both of those sound reasonable to me. Would you want to take a stab at
implementing it and providing a patch?

Best,

Marc

James Buckingham

unread,
Oct 6, 2010, 8:08:35 AM10/6/10
to mxunit
We'd certainly be willing to give it a look :-)

What's the procedure with that kind of thing?

Marc Esher

unread,
Oct 6, 2010, 9:29:00 AM10/6/10
to mxu...@googlegroups.com
1) Write Code
2) create a svn patch file
3) fame!

If you are interested, we can talk about it off-list to hammer out our
ideas for how to proceed


On Wed, Oct 6, 2010 at 8:08 AM, James Buckingham <clar...@gmail.com> wrote:
> We'd certainly be willing to give it a look :-)
>
> What's the procedure with that kind of thing?
>

Reply all
Reply to author
Forward
0 new messages