Re: [mxunit:3737] some basic mxunit queries

45 views
Skip to first unread message
Message has been deleted

Marc Esher

unread,
Oct 25, 2012, 3:01:54 PM10/25/12
to mxu...@googlegroups.com
Hey Dan,

Sorry for the late reply.

The problem is that you're running the test incorrectly. It should be run like so:


That will run all tests in your TestCase.

If you want to run a single test method in a testcase, you'll do this:


Marc

On Mon, Oct 22, 2012 at 9:47 AM, Dan <roo...@gmail.com> wrote:
Hi,
I've got a couple of queries on MXunit and asserts. I've have the following code, 1 cfc and 1 test cfc which I invoke via my browser: http://127.0.0.1:8500/mxunit/tests/mycomponenttest.cfc?method=testadd

mycomponent.cfc
<cfcomponent>
<cffunction name="add" access="public" returntype="numeric">
<cfargument name="num1">
<cfargument name="num2">
<cfreturn num1+num2>
</cffunction>
</cfcomponent>


mycomponentTEST.cfc
<cfcomponent displayname="mxunit.framework.MyComponentTest"  extends="mxunit.framework.TestCase">
<cffunction name="testAdd" access="remote" returntype="void">
<cfinvoke component = "mycomponent"  method = "add"  returnVariable = "result" >
<cfinvokeargument name="num1" value="3"> 
   <cfinvokeargument name="num2" value="3"> 
</cfinvoke>
<cfset asserttrue (3,"error")>
</cffunction>
</cfcomponent>

When I run mycomponentTEST.cfc I get a blank page back.How come? Is my asserttrue incorrect? Any pointers much appreciated.


I've tried replacing the assert with  <cfset assertequals(1,2)> and get this :
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator. 


The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request

:: Expected [1] BUT RECEIVED [2]. These values should be the same.

 
The error occurred in C:\ColdFusion8\wwwroot\mxunit\framework\Assert.cfc: line 176
Called from C:\ColdFusion8\wwwroot\mxunit\framework\Assert.cfc: line 267
Called from C:\ColdFusion8\wwwroot\mxunit\tests\mycomponenttest.cfc: line 11
174 : 			<cfset variables.actual = arguments.actual>
175 : 		</cfif>
176 : 	    <cfthrow type="mxunit.exception.AssertionFailedError" message="#arguments.message#:: Expected [#getStringValue(arguments.expected,arguments.caseSensitive)#] BUT RECEIVED [#getStringValue(arguments.actual,arguments.caseSensitive)#]. These values should be the same. " />
177 : 	  </cffunction>
178 : 

--
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/-/DBN2Accby4AJ.
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.

Dan

unread,
Nov 2, 2012, 5:57:32 AM11/2/12
to mxu...@googlegroups.com
Many thanks Mark. I got it working as you pointed out.

Marc Esher

unread,
Nov 2, 2012, 8:20:48 AM11/2/12
to mxu...@googlegroups.com
Good to hear it, Dan. Happy testing.


To view this discussion on the web visit https://groups.google.com/d/msg/mxunit/-/hOUlQJ-kc7cJ.
Reply all
Reply to author
Forward
0 new messages