Jonathan,
I'm reasonably new to this so take this with a grain of salt, but here's how I handle this:
You need to avoid ORM functions like entityLoad/entityNew/etc in your testable functions.
This means you need to abstract them into service objects. Then you can stub out the service objects in your tests in the same way you're stubbing DocumentDB.
e.g:
<cfcomponent displayname=”DocumentDAO” output=”no”>
<cffunction name=”loadDocument” returntype=”Document” output=”no”>
<cfargument name=”documentId” type=”numeric” required=”yes” />
<cfreturn entityLoad(“Document”, arguments.documentId, true) />
</cffunction>
</cfcomponent>
And your code:
<!--- snip --->
for ( intRow = 1 ; intRow LTE local.q_docs.RecordCount; intRow = (intRow + 1) ) {
local.document = variables.DocumentDAO.loadDocument(local.q_docs[ "DocumentID" ][ intRow ]);
ArrayAppend(local.returnArray, local.document);
}
<!--- snip --->
I take it further and run my tests using a runner in a subfolder with its own Application.cfc which does not have ORM enabled. This means any calls to ORM functions will throw errors - the idea is to completely isolate your unit tests from real DB interaction.
John.
--
You received this message because you are subscribed to the Google Groups "mxunit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
mxunit+un...@googlegroups.com.
To post to this group, send email to
mxu...@googlegroups.com.
Visit this group at
http://groups.google.com/group/mxunit.
For more options, visit
https://groups.google.com/d/optout.
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.