Re: [mxunit:3799] Creating a simple application to test with MXUnit in FW/1

243 views
Skip to first unread message

Marc Esher

unread,
Dec 14, 2012, 2:20:42 PM12/14/12
to mxu...@googlegroups.com
First, you don't need to put mxunit inside your application.

Second, the simplest thing is to:

A) create a "tests" directory in your app
B) put your tests in there. Tests either start or end with Test, like "MyTest.cfc" or "TestThingie.cfc".

As for getting started writing tests, you could start at the "Testing Basics" section of wiki.mxunit.org. If you're already familiar with writing tests but are more inquiring about writing tests in the context of fw/1, my gut advice is to try not to think about fw/1 at all! Your tests needn't know anything about the framework under which your application runs. Strive for decoupling.

For example, if you have a RobotService.cfc, and it has methods like makeBed() and driveCar(), your tests will simply instantiate a new RobotService, call those methods, and make assertions on results:

component extends="mxunit.framework.TestCase"{

  function setUp(){
    robotService = new RobotService();
  }

  robot_should_use_blankets_when_making_bed(){
     var result = robotService.makeBed(..);
     assertTrue( results.blanketsUsed ); 
  }

}

As your components under test take on new behavior, you'll add tests. As you attempt to more thoroughly test the behaviors, you'll add tests. Repeat that process till your components under test are as thoroughly tested as you can get them. 

Marc


On Fri, Dec 14, 2012 at 11:50 AM, MarkBanker <mark....@gmail.com> wrote:
Our applications use FW/1 and my goal is to get us using MXUnit with FW/1. This all has me a bit confused. Here is the basic structure inclusive of mxunit.

\testAppRoot
\controllers
\layouts
\mxunit
\services
\views
Application.cfc
index.cfm

FW/1 and MXUnit properly integrated I would like to create a simple application to test. I don't know where I am supposed to put all of the different files. I need some help getting started. Is anyone aware of a good tutorial or example of using FW/1 and MXUnit together?

Thank you for any help you can provide.

Mark

--
You received this message because you are subscribed to the Google Groups "mxunit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mxunit/-/3Lg9koTfZrkJ.
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.

MarkBanker

unread,
Dec 14, 2012, 3:01:43 PM12/14/12
to mxu...@googlegroups.com
Marc,
 
You gave me the perfect answer! I got exactly what I needed. I know how to write the tests, I just needed to know where I put what. The other sage advice was to ignore FW/1.
 
I am having one issue now and that is that when I run the 'Test Facade URL' from within CFEclipse it doesn't work. The ping works properly from the URL. I know this isn't the proper place to post this question so I will post it in the Eclipse section.
 
Thanks again,
 
Mark

Marc Esher

unread,
Dec 14, 2012, 3:23:00 PM12/14/12
to mxu...@googlegroups.com
Mark,

   I'd say you're in the right place for asking this, as I wrote the Eclipse plugin.

When you try to run the tests from Eclipse, what errors do you get? What behavior do you see? 

Also, open up the Eclipse error log (window -- show view -- error log) and look at the latest entries. You should see entries specifically for the mxunit plugin.

Marc


To view this discussion on the web visit https://groups.google.com/d/msg/mxunit/-/IgIC5H4lGkgJ.

Mark Banker

unread,
Dec 14, 2012, 3:38:51 PM12/14/12
to mxu...@googlegroups.com
Wow am I lucky to have found you! The ping works in the browser as well as the wsdl shows.

Message: RemoteException calling getServerType

Stack Trace:
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: org.xml.sax.SAXParseException: Premature end of file.
 faultActor:
 faultNode:
 faultDetail:
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.mxunit.eclipseplugin.actions.bindings.generated.RemoteFacadeCfcSoapBindingStub.getServerType(RemoteFacadeCfcSoapBindingStub.java:382)
    at org.mxunit.eclipseplugin.actions.util.RemoteCallCreator.initFacade(RemoteCallCreator.java:73)
    at org.mxunit.eclipseplugin.actions.util.RemoteCallCreator.canPingFacade(RemoteCallCreator.java:52)
    at org.mxunit.eclipseplugin.properties.MXUnitPropertyPage$1.widgetSelected(MXUnitPropertyPage.java:126)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:158)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

    {http://xml.apache.org/axis/}hostname:marban

org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.mxunit.eclipseplugin.actions.bindings.generated.RemoteFacadeCfcSoapBindingStub.getServerType(RemoteFacadeCfcSoapBindingStub.java:382)
    at org.mxunit.eclipseplugin.actions.util.RemoteCallCreator.initFacade(RemoteCallCreator.java:73)
    at org.mxunit.eclipseplugin.actions.util.RemoteCallCreator.canPingFacade(RemoteCallCreator.java:52)
    at org.mxunit.eclipseplugin.properties.MXUnitPropertyPage$1.widgetSelected(MXUnitPropertyPage.java:126)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:158)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    ... 49 more

Marc Esher

unread,
Dec 14, 2012, 5:33:18 PM12/14/12
to mxu...@googlegroups.com
OK, if you're pointing to a custom remote facade and you're using CF 10, you'll need to follow these simple instructions: http://wiki.mxunit.org/display/default/Using+the+Eclipse+Plugin+against+ColdFusion+10

But that doesn't sound like the problem.

What version of CF are you running? What's the URL to your remote facade? And what version of MXUnit are you using? You can find it by looking at the bottom of the screen when you load mxunit/index.cfm in your browser on your system.

And please confirm that the "dot path" is correct in your mxunit project properties. You'll know it's correct if, when you try to run a test, it shows up in the mxunit view with the correct path as ColdFusion would see it, something like "myproject.tests.MyTest"

Finally, the "Remote Facade Tester" can also be helpful. It's described here and its purpose is to figure out whether the problem is on the server or within eclipse: http://wiki.mxunit.org/display/default/Eclipse+Plugin+Troubleshooting

Marc

Mark Banker

unread,
Dec 14, 2012, 6:08:14 PM12/14/12
to mxu...@googlegroups.com
remote facade URL:  http://emails.marco.com.localhost/lancer/_dev/tests/mxunit/RemoteFacade.cfc?wsdl
It works in an external browser as well as Eclipse's internal browser.

Dot path is lancer._dev.tests.mxunit

The test in the project properties does not work. I get an error at the test in the project properties as well as if I try to run a test.

I am using CF9.
MXUnit Version Info: This is a nightly build of the 2.0.3 stream, built on 09/09/2011

Thank you Marc!

Marc Esher

unread,
Dec 14, 2012, 6:40:18 PM12/14/12
to mxu...@googlegroups.com
First, I'd advise running the latest versions of both the eclipse plugin and the mxunit framework.

However, I don't think that's your problem. Something's getting in the way of Eclipse and your tests. My guess is that it's FW1 itself and the onRequest() method. I think there's a config option for telling FW1 to ignore certain paths, and so you'll likely need to set that such that it stops intercepting the request to your tests

As I said earlier, if you use the RemoteFacadeTester as outlined in that wiki page, it'll use coldfusion to run your test in exactly the same manner as the eclipse plugin does. That sometimes makes it easier to find out what's going on in the server.

Marc

Chris Blackwell

unread,
Dec 17, 2012, 4:25:09 AM12/17/12
to mxu...@googlegroups.com
FW/1 is greedy and will try to eat all requests unless you tell it otherwise.
You'll need to set

variables.framework.unhandledPaths = '/tests";

Then FW/1 will let the request complete without interfering

Chris

Marc Esher

unread,
Dec 17, 2012, 7:22:54 AM12/17/12
to mxu...@googlegroups.com
Thanks, Chris.
Reply all
Reply to author
Forward
0 new messages