Listing 1: cfdjtests.unittest1 – simple test

<cfcomponent
	extends="org.cfcunit.framework.TestCase"
	hint="CFDJ Sample 1, simple CFCUnit Test"
	output="false">
	<!---
		current assert list:
			assertTrue
			assertFalse
			assertSimpleValue
			assertComplexValue
			assertComponent
			assertObject
			assertEqualsString
			assertEqualsNumber
			assertEqualsBoolean
			assertEqualsStruct
			assertEqualsArray
			assertSameStruct
			assertSameComponent
			assertNotSameStruct
			assertNotSameComponent
			assertNull
			assertNullComponent
			assertNotNull

			assertNotNullComponent
	 --->
<cffunction name="testAssertComplexValue" returntype="void" access="public"
	 output="false">
		<cfset assertComplexValue(StructNew())>
	</cffunction>
	<cffunction name="testAssertSameComponent" returntype="void"
	access="public" output="false">
		<cfset var obj1 = CreateObject("component",
		"org.cfcunit.samples.money.money")>

		<cfset assertSameComponent(obj1, obj1)>
	</cffunction>
	<!--- this test will fail --->
	<cffunction name="testAssertOtherComponent" returntype="void"
	access="public" output="false">
		<cfset var obj1 = CreateObject("component",
		 "org.cfcunit.samples.money.money")>
		<cfset var obj2 = CreateObject("component",
		"org.cfcunit.samples.money.moneybag")>
		<cfset assertSameComponent(obj1, obj2)>
	</cffunction>
</cfcomponent>


Listing 2: cfdjtests.unittest2

<cfcomponent
	extends="org.cfcunit.Object"
	hint="CFDJ Sample 2, run sample 1"
	output="false">
	<cffunction name="suite" returntype="org.cfcunit.framework.Test"
	access="public" output="false" hint="">
		<cfset var testSuite =
	newObject("org.cfcunit.framework.TestSuite").init("CFDJ Tests")>
<cfset testSuite.addTestSuite(newObject("cfdjtests.unittest1"))>
		<!--- add more tests to this testsuite ... --->
		<cfreturn testSuite/>
	</cffunction>
</cfcomponent>

Source Code...for This Article 1.23 KB