[Testbox 2.1.0] - Method counters not working?

10 views
Skip to first unread message

CaptainPalapa

unread,
May 28, 2015, 12:04:43 PM5/28/15
to col...@googlegroups.com
I am confused.  I have an xUnit test case, the function as follows:

public function testNotify(){
local.oListenerService = createObject(variables.sModelPath).init();
local.oMockObserverService = createObject('component', 'test.mocks.mockObserverService');
mockbox.prepareMock(local.oMockObserverService);
local.oListenerService.register(local.oMockObserverService);
local.oListenerService.notify('test topic', {});
debug(local.oMockObserverService.$count('notify'));  // Shows -1
$assert.isTrue(local.oMockObserverService.$once('notify'));  // Assertion fails.
}


The assertion at the end fails as if the ListenerService never passes on a notify() call to my Observer.  However, I know that it does indeed call it, because if I put a <cfdump var="x" /><cfabort /> in the Observer's notify() function, I get the dump/abort.

I grabbed the latest Testbox (with Mockbox included) and from the website and the versions listed in system\Testbox.cfc and Mockbox.cfc are the same as in the new .zip I downloaded.

Yes, by the way, I have tried adding a true flag to the prepareMock() call, but true is the default anyway.  Made no difference.   The mock object, when dumped, shows that _MockCallLoggingActive=true, though the _MockCallLoggers struct is empty.

Stumped.  Thoughts, anyone?   Am I using it wrong?

Luis Majano

unread,
May 31, 2015, 4:24:48 PM5/31/15
to col...@googlegroups.com
Yes. You are not mocking the function. You need to mock the function do mock box can track it. 

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057




--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/a7544358-7385-4aae-9ffa-a19abee436f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Will Belden

unread,
Jun 1, 2015, 10:39:14 AM6/1/15
to col...@googlegroups.com
You are right, I did forget that.  But now when I add the mock with $('notify')....I keep getting errors that I'm not meeting my interface.  Is that any kind of known issue?

Actually, I had to rename my function from notify() to announce() because Coldfusion (after adding the $() call) that "notify" is a built in CF function.  (Though I can't find that anywhere in any documentation.)   And yes, I did catch all the renames.  I triple checked upon getting this problem.
Reply all
Reply to author
Forward
0 new messages