We're updating the issue view to help you get more done. 

Docs for Assertion CFCs inadequate, or functionality just doesn't work?


I'm reading this: http://wiki.coldbox.org/wiki/TestBox.cfm#Assertion_Registration, specifically the "CFC Assertions" bit.

I can get Testbox to call in a CFC using this:

1 addAssertions("tests.testbox.CustomAssertions");

But as soon as I put any functions in the CFC, my test run starts erroring with:

Complex object types cannot be converted to simple values.

The expression has requested a variable or an intermediate expression result as a simple value. However, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
The most likely cause of the error is that you tried to use a complex value as a simple one. For example, you tried to use a query variable in a cfif tag.

The error occurred in C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/frameworks/testbox/1.0.0/testbox/system/testing/BaseSpec.cfc: line 338
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/shared/git/cflib/makeStopwatch/TestMakeStopwatch.cfc: line 5
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/frameworks/testbox/1.0.0/testbox/system/testing/runners/UnitRunner.cfc: line 52
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/frameworks/testbox/1.0.0/testbox/system/testing/TestBox.cfc: line 323
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/frameworks/testbox/1.0.0/testbox/system/testing/TestBox.cfc: line 161
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/frameworks/testbox/1.0.0/testbox/system/testing/TestBox.cfc: line 94
Called from C:/apps/adobe/ColdFusion/10/cfusion/wwwroot/shared/git/cflib/makeStopwatch/runTests.cfm: line 6
336 : var methodArray = structKeyArray( oAssertions );
337 : for( var thisMethod in methodArray ){
338 : this.$assert[ thisMethod ] = oAssertions[ methodArray ];
339 : }
340 :

TestMakeStopwatch.cfc: line 5 is the call to addAssertions()

Also: the docs for custom assertions say this:

The function should return itself (this) if the actual value passes

You'd better clarify what you want ppl to return when the function is in a CFC, because within a CFC, this refers to the CFC, not the function. I presume you mean this:

1 2 3 4 5 6 function myAssertion(condition){ if (condition){ return myAssertion; // ie: a reference to itself } fail("condition was false"); }


An example CFC in the docs is probably necessary here.



Luis Majano


Adam Cameron




Fix versions

Affects versions