Created
July 14, 2010 21:07
-
-
Save virtix/476072 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="mxunit.framework.TestCase"> | |
<cfscript> | |
/** | |
* Assume cut has two methods: calculate() and getDataFromDatabase(). | |
* getDataFromDatabase() goes to a Db, which we want to control, and | |
* calculate() calls getDataFromDatabase(). We want to stub only getDataFromDatabase(). | |
* | |
* This "partial" mocking allows one to run tests on a component and mock specific methods | |
* in that component. | |
*/ | |
function partialMockingSyntax(){ | |
cut = mock( 'com.foo.bar' ); | |
cut.when().getDataFromDatabase().returns( someQueryObject ); | |
assertEquals( expected, cut.calculate() ); | |
} | |
</cfscript> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment