I’m getting my hands dirty using MXUnit Testing w/ MockBox recently. The basics where fairly easy to pickup, but I’ve now hit a road block. Lets say I need to test this method:
<cfcomponent extends="message" output="false"> <cffunction name="send" access="public" returntype="void" output="false"> <cfargument name="name" type="string" required="true"> <cfif name neq "test"> <cfset super.send(name=arguments.name)> </cfif> </cffunction> </cfcomponent>
So following unit test ideology, I should just test what’s happening in this method and not attached methods. If I had instantiated an object or the method was in the some component I could just mock the method being called. However since the method is located in the component’s parent, this does not appear to be working. The test contains:
variables.mockBox = new mockbox.MockBox(); variables.component = CreateObject('component', 'thisComponent'); variables.mockBox.prepareMock(variables.component); variables.component.super.$('send');
This returns the error: “Expression: Element COMPONENT.SUPER is undefined in a Java object of type class [Ljava.lang.String; referenced as ””.
Now technically I could wrap the super.send call inside another local method and mock that method. However that would be coding for the test and would be worthless code and processor usage outside the test.
I’ve Googled this and searched ColdBox’s site for a solution to this, however I’m not getting anywhere.
Does anyone have any ideas or suggestions?