Creating a test with a <cfthread> causes the thread to show up as a unit test

2 views
Skip to first unread message

ken.sykora

unread,
Apr 23, 2008, 10:38:01 AM4/23/08
to mxunit
Hi Everyone -

I've started using mxunit in my projects, and so far I am in love.
I've run into one strange issue though. I'm writing tests to test
concurrency issues, and using <cfthread> to achieve this, but I
noticed that whenever you create a unit test with a call to <Cfthread>
in it, the thread shows up as a function in the unit test. The "fake"
tests created by the threads actually run, but they fail if you make a
reference to the attributes scope.

This isn't a huge deal, because I can just not run those weird tests
that are created but it could be problematic with ANT integration.

Example:

<cfcomponent output="false" extends="mxunit.framework.TestCase">

<cffunction name="thread_10Factorial">

<cfset var i = "">
<cfset results = structnew()>

<cfset assertTrue(true,"sanity check failed")>

<cfloop from="1" to="10" index="i">
<cfthread action="run" name="#i#" threadID="#i#">
<cfset thread.result = 1>
<cfloop from="1" to="10" index="thread.j">
<cfset thread.result = thread.result * thread.j>
</cfloop>
<cfset results[attributes.threadID] = thread.result>
</cfthread>
</cfloop>

<cfloop from="1" to="10" index="i">
<cfthread action="join" name="#i#"/>
<cfset assertEquals(results[i],3628800,"Did not compute 10!")>
</cfloop>
</cffunction>

</cfcomponent>

Marc Esher

unread,
Apr 23, 2008, 11:31:01 AM4/23/08
to mxu...@googlegroups.com
Fascinating. Damn fine bug. A Fix will be forthcoming sometime within
the next day or two.

Thanks Ken.

Marc

ken.sykora

unread,
Apr 24, 2008, 9:48:38 AM4/24/08
to mxunit
I logged this as a bug as well:

http://code.google.com/p/mxunit/issues/detail?id=107

On Apr 23, 10:31 am, "Marc Esher" <marc.es...@gmail.com> wrote:
> Fascinating. Damn fine bug. A Fix will be forthcoming sometime within
> the next day or two.
>
> Thanks Ken.
>
> Marc
>
Reply all
Reply to author
Forward
0 new messages