Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents 4763f53 + 83ce099 commit 49dd108d0c8eedd8b7b817d390702f0cff82b7dc @marcesher marcesher committed Aug 10, 2012
View
5 .gitignore
@@ -1,11 +1,10 @@
+.*
+!.gitignore
settings.xml
-.settings/
-.project
MXUnitInstallTest.cfc
buildprops/antrunner.properties
tests/testresults/
*.iml
-
/WEB-INF
/doc
/dist
View
287 PluginDemoTests/HodgePodgeTest.cfc 100644 → 100755
@@ -1,130 +1,159 @@
-<cfcomponent extends="mxunit.framework.TestCase">
- <cfset MyStruct = StructNew()>
- <cfset MyStruct.SomeData = "blahhhhhhh wahahahaha">
-
- <cffunction name="setUp" output="false" access="public" returntype="void" hint="">
-
- </cffunction>
-
- <cffunction name="tearDown" output="false" access="public" returntype="void" hint="">
- <!--- to be safe, since i know i'm monkeying with abandon up in this mofo --->
- <cfset setTestStyle("default")>
- </cffunction>
-
-
- <cffunction name="testOK">
- <cfset var q = QueryNew("one,two")>
- <cfset assertTrue(true,"true")>
- <cfoutput>Hi mommmmm is< valid? what about & </cfoutput>
- <cfdump var="#MyStruct#">
- <cfset QueryAddRow(q)>
- <cfset QuerySetCell(q,"one","one")>
- <cfset QuerySetCell(q,"two","two")>
- <cfdump var="#q#">
- <cfset addTrace("Hi mom")>
- </cffunction>
-
- <cffunction name="testDoSomething">
- <cfset debug("inside testDoSomething")>
- <cfset obj = createObject("component","SomeObject")>
- <cfset obj.doSomething()>
- </cffunction>
-
- <cffunction name="testRequestDotDebug">
- <cfset obj = createObject("component","SomeObject")>
- <cfset debug("before the object calls request.debug")>
- <cfset obj.thisWillOnlyWorkInThePlugin()>
- <cfset debug("after a function that called request.debug")>
- </cffunction>
-
- <cffunction name="testRequestDotDebug_WillShowUpWithoutDebugBeingCalledFirst">
- <cfset obj = createObject("component","SomeObject")>
- <cfset obj.thisWillOnlyWorkInThePlugin()>
- </cffunction>
-
- <cffunction name="testRequestDotDebug_WillPassInBothPluginAndWeb">
- <cfset createRequestScopeDebug()>
- <cfset obj = createObject("component","SomeObject")>
- <cfset debug("before the object calls request.debug")>
- <cfset obj.thisWillOnlyWorkInThePlugin()><!--- only work in plugin.... unless we explictly enable it in the test!!! --->
- <cfset debug("after a function that called request.debug")>
- <cfset stopRequestScopeDebug()>
- </cffunction>
-
- <cffunction name="testDoSomethingThenExitToGetDump">
- <cfset obj = createObject("component","SomeObject")>
- <cfset obj.doSomethingThenExitToGetDump()>
- </cffunction>
-
-
-
- <cffunction name="testFail" returntype="void" hint="">
- <cfoutput>wooopity doo!</cfoutput>
- <cfset debug("blah")>
- <cfset fail("failing intentionally")>
- </cffunction>
-
- <cffunction name="testNotEquals" returntype="void">
- <cfset assertEquals("#repeatString('hey nonny ',10)#", "#repeatString('hey ninny ',10)#")>
- </cffunction>
-
- <cffunction name="testError" returntype="void" hint="">
- <cfset debug(arraynew(1))>
- <cfset debug("throwing error from inside testError before i throw intentionally")>
- <cfthrow message="throwing error intentially">
- </cffunction>
-
- <cffunction name="throwErrorFromComponentNotInWorkspace" output="false" access="public" returntype="any" hint="calls a component that isn't in the cfeclipse workspace">
- <cfset var sc = createObject("component","SomeComponent")>
- <cfset sc.saySomething()>
- <cfset sc.throwAnError()>
- </cffunction>
-
- <cffunction name="testAnotherError" returntype="void" hint="">
- <cfinvoke component="mxunit.framework.Formatters" method="toStructs" xml="invalidxml" returnvariable="nothin">
- </cffunction>
-
- <cffunction name="testWithDebug">
- <cfset debug(StructNew())>
- <cfset debug(arraynew(1))>
- <cfdump var="#getDebug()#">
- </cffunction>
-
- <cffunction name="testPrivate" output="false" access="private">
- <cfthrow message="this is private and should never run">
- </cffunction>
-
- <cffunction name="testPackage" output="false" access="package">
- <cfthrow message="this is package and should never run">
- </cffunction>
-
- <cffunction name="testAssertTrueFailing" output="false" access="public" returntype="any" hint="">
- <cfset assertTrue(1 eq 2,"this should fail because one equals two is not true")>
- </cffunction>
-
- <cffunction name="testAssertTrueFailingWithoutMessage" output="false" access="public" returntype="any" hint="">
- <cfset assertTrue(1 eq 2)>
- </cffunction>
-
- <cffunction name="testAssertTrueOK">
- <cfset assertTrue(1 eq 1,"")>
- </cffunction>
-
- <cffunction name="testAssertTrueCFCUnitStyle">
- <cfset setTestStyle("default")>
- <cfset assertTrue(1 eq 1,"OK")>
- <cfset assertTrue(1 eq 1)>
- </cffunction>
-
- <cffunction name="testAssertTrueCFCUnitStyleFailure">
- <cfset setTestStyle("default")>
- <cfset assertTrue(1 eq 2,"1 does not equal 2")>
- </cffunction>
-
- <cffunction name="testAssertTrueCFUnitStyleFailure">
- <cfset setTestSTyle("cfunit")>
- <cfset assertTrue("false ain't true, sucka",false)>
- </cffunction>
-
-
+<cfcomponent extends="mxunit.framework.TestCase">
+ <cfset MyStruct = StructNew()>
+ <cfset MyStruct.SomeData = "blahhhhhhh wahahahaha">
+
+ <cffunction name="setUp" output="false" access="public" returntype="void" hint="">
+
+ </cffunction>
+
+ <cffunction name="tearDown" output="false" access="public" returntype="void" hint="">
+ <!--- to be safe, since i know i'm monkeying with abandon up in this mofo --->
+ <cfset setTestStyle("default")>
+ </cffunction>
+
+
+
+ <cffunction name="testOK">
+ <cfset var q = QueryNew("one,two")>
+ <cfset assertTrue(true,"true")>
+ <cfoutput>Hi mommmmm is< valid? what about & </cfoutput>
+ <cfdump var="#MyStruct#">
+ <cfset QueryAddRow(q)>
+ <cfset QuerySetCell(q,"one","one")>
+ <cfset QuerySetCell(q,"two","two")>
+ <cfdump var="#q#">
+ <cfset addTrace("Hi mom")>
+ </cffunction>
+
+ <cffunction name="testDoSomething">
+ <cfset debug("inside testDoSomething")>
+ <cfset obj = createObject("component","SomeObject")>
+ <cfset obj.doSomething()>
+ </cffunction>
+
+ <cffunction name="testRequestDotDebug">
+ <cfset obj = createObject("component","SomeObject")>
+ <cfset debug("before the object calls request.debug")>
+ <cfset obj.thisWillOnlyWorkInThePlugin()>
+ <cfset debug("after a function that called request.debug")>
+ </cffunction>
+
+ <cffunction name="testRequestDotDebug_WillShowUpWithoutDebugBeingCalledFirst">
+ <cfset obj = createObject("component","SomeObject")>
+ <cfset obj.thisWillOnlyWorkInThePlugin()>
+ </cffunction>
+
+ <cffunction name="testRequestDotDebug_WillPassInBothPluginAndWeb">
+ <cfset createRequestScopeDebug()>
+ <cfset obj = createObject("component","SomeObject")>
+ <cfset debug("before the object calls request.debug")>
+ <cfset obj.thisWillOnlyWorkInThePlugin()><!--- only work in plugin.... unless we explictly enable it in the test!!! --->
+ <cfset debug("after a function that called request.debug")>
+ <cfset stopRequestScopeDebug()>
+ </cffunction>
+
+ <cffunction name="testDoSomethingThenExitToGetDump">
+ <cfset obj = createObject("component","SomeObject")>
+ <cfset obj.doSomethingThenExitToGetDump()>
+ </cffunction>
+
+
+
+ <cffunction name="testFail" returntype="void" hint="">
+ <cfoutput>wooopity doo!</cfoutput>
+ <cfset debug("blah")>
+ <cfset fail("failing intentionally")>
+ </cffunction>
+
+ <cffunction name="testNotEquals" returntype="void">
+ <cfset assertEquals("#repeatString('hey nonny ',10)#", "#repeatString('hey ninny ',10)#")>
+ </cffunction>
+
+ <cffunction name="testError" returntype="void" hint="">
+ <cfset debug(arraynew(1))>
+ <cfset debug("throwing error from inside testError before i throw intentionally")>
+ <cfthrow message="throwing error intentially">
+ </cffunction>
+
+ <cffunction name="throwErrorFromComponentNotInWorkspace" output="false" access="public" returntype="any" hint="calls a component that isn't in the cfeclipse workspace">
+ <cfset var sc = createObject("component","SomeComponent")>
+ <cfset sc.saySomething()>
+ <cfset sc.throwAnError()>
+ </cffunction>
+
+ <cffunction name="testAnotherError" returntype="void" hint="">
+ <cfinvoke component="mxunit.framework.Formatters" method="toStructs" xml="invalidxml" returnvariable="nothin">
+ </cffunction>
+
+ <cffunction name="testWithDebug">
+ <cfset debug(StructNew())>
+ <cfset debug(arraynew(1))>
+ <cfdump var="#getDebug()#">
+ </cffunction>
+
+ <cffunction name="testPrivate" output="false" access="private">
+ <cfthrow message="this is private and should never run">
+ </cffunction>
+
+ <cffunction name="testPackage" output="false" access="package">
+ <cfthrow message="this is package and should never run">
+ </cffunction>
+
+ <cffunction name="testAssertTrueFailing" output="false" access="public" returntype="any" hint="">
+ <cfset assertTrue(1 eq 2,"this should fail because one equals two is not true")>
+ </cffunction>
+
+ <cffunction name="testAssertTrueFailingWithoutMessage" output="false" access="public" returntype="any" hint="">
+ <cfset assertTrue(1 eq 2)>
+ </cffunction>
+
+ <cffunction name="testAssertTrueOK">
+ <cfset assertTrue(1 eq 1,"")>
+ </cffunction>
+
+ <cffunction name="testAssertTrueCFCUnitStyle">
+ <cfset setTestStyle("default")>
+ <cfset assertTrue(1 eq 1,"OK")>
+ <cfset assertTrue(1 eq 1)>
+ </cffunction>
+
+ <cffunction name="testAssertTrueCFCUnitStyleFailure">
+ <cfset setTestStyle("default")>
+ <cfset assertTrue(1 eq 2,"1 does not equal 2")>
+ </cffunction>
+
+ <cffunction name="testAssertTrueCFUnitStyleFailure">
+ <cfset setTestSTyle("cfunit")>
+ <cfset assertTrue("false ain't true, sucka",false)>
+ </cffunction>
+
+ <cffunction name="appendMock" returntype="string">
+ <cfargument name="val">
+ <cfreturn "xx" >
+ </cffunction>
+
+ <cffunction name="append" returntype="string">
+ <cfargument name="val">
+ <cfreturn "xx" >
+ </cffunction>
+
+ <cffunction name="testRestoreMethod" access="public" returntype="void">
+ <cfset var mycomp = createObject("component" ,"SomeObject") />
+
+ <cfset assertEquals("foo ", mycomp.append(""))>
+ <cfset assertEquals("foo bar", mycomp.append("bar"))>
+
+
+ <cfset injectMethod(mycomp,this,"appendMock","append") />
+ <cfset assertEquals("xx", mycomp.append("bar"))>
+
+
+ <cfset restoreMethod(mycomp, "append" ) />
+ <cfset debug(mycomp.append('bar'))>
+ <cfset assertEquals("foo bar", mycomp.append("bar"))>
+
+
+ </cffunction>
+
+
</cfcomponent>
View
10 PluginDemoTests/SomeObject.cfc 100644 → 100755
@@ -20,4 +20,14 @@
<cfset request.debug("and some more!")>
</cffunction>
+ <cffunction name="append">
+ <cfargument name="stuff">
+ <cfreturn "foo #stuff#">
+ </cffunction>
+
+ <cffunction name="append2">
+ <cfargument name="stuff">
+ <cfreturn "foo #stuff#">
+ </cffunction>
+
</cfcomponent>
View
32 framework/Assert.cfc
@@ -35,7 +35,15 @@ Main component for performing assertions.
assert function and thus mxunit won't run on BD unless we do this --->
<cffunction name="init" access="remote" returntype="Assert" hint="Constructor">
- <cfset addAssertDecorators() />
+ <cfscript>
+ //do a feature check for pass by value.
+ var arr1 = [];
+ var arr2 = arr1;
+ var System = createObject("java", "java.lang.System");
+ variables.arraysPassByValue = System.identityHashCode(arr1) != System.identityHashCode(arr2);
+
+ addAssertDecorators();
+ </cfscript>
<!---
Leave this out for now ...
<cfscript>
@@ -390,7 +398,7 @@ assert function and thus mxunit won't run on BD unless we do this --->
var expect = system.identityHashCode(arguments.expected);
var act = system.identityHashCode(arguments.actual);
//Arrays are passed by value in CF ...
- if(isArray(arguments.expected) or isArray(arguments.actual)){
+ if(isPassByValueArray(arguments.expected) or isPassByValueArray(arguments.actual)){
throwWrapper("mxunit.exception.CannotCompareArrayReferenceException","Cannot compare array references in ColdFusion","Arrays in ColdFusion are passed by value. To compare instances, you may wrap the array in a struct and compare those.");
}
if(expect eq act){
@@ -412,7 +420,7 @@ assert function and thus mxunit won't run on BD unless we do this --->
var expect = system.identityHashCode(arguments.expected);
var act = system.identityHashCode(arguments.actual);
//Arrays are passed by value in CF ...
- if(isArray(arguments.expected) or isArray(arguments.actual)){
+ if(isPassByValueArray(arguments.expected) or isPassByValueArray(arguments.actual)){
throwWrapper("mxunit.exception.CannotCompareArrayReferenceException","Cannot compare array references in ColdFusion","Arrays in ColdFusion are passed by value. To compare instances, you may wrap the array in a struct and compare those.");
}
if(not expect eq act){
@@ -478,7 +486,25 @@ assert function and thus mxunit won't run on BD unless we do this --->
</cffunction>
+ <cffunction name="isPassByValueArray" hint="Checks to see if this is an array that will pass by value" access="private" returntype="boolean" output="false">
+ <cfargument name="value" hint="an object" type="any" required="true">
+ <!---
+ Adobe ColdFusion arrays pass by value.
+ Railo passes by reference
+ OpenBD? apparently can sometimes.
+ --->
+ <cfscript>
+ var className = 0;
+ if(NOT variables.arraysPassByValue OR NOT isArray(arguments.value))
+ {
+ return false;
+ }
+ className = arguments.value.getClass().getName();
+
+ return className contains "coldfusion." OR className contains ".nary";
+ </cfscript>
+ </cffunction>
</cfcomponent>
View
3 framework/ComponentBlender.cfc
@@ -37,11 +37,12 @@
<cfargument name="newPropertyName" type="string" required="true"/>
<cfargument name="ignoreIfExisting" type="boolean" required="false" default="true">
- <cfif ignoreIfExisting AND structKeyExists( variables, newPropertyName )>
+ <cfif ignoreIfExisting AND structKeyExists( variables, newPropertyName )>
<cfreturn>
</cfif>
<cfif structKeyExists( variables, propertyName )>
<cfset variables[newPropertyName] = variables[propertyName]>
+ <cfset this[newPropertyName] = variables[newPropertyName]>
</cfif>
</cffunction>
View
26 framework/RemoteFacade.cfc
@@ -49,6 +49,25 @@
<cffunction name="endTestRun" access="remote" returntype="string" hint="ensures proper cleanup">
<cfargument name="TestRunKey" type="string" required="true" hint="the key returned from startTestRun; used for managing the pool of components">
+
+ <!---run all components' afterTests() --->
+ <cfset var pool = cache.getSuitePool()>
+ <cfset var componentName = "">
+ <cfset var testCase = "">
+
+ <cfif structKeyExists( pool, testRunKey )>
+ <cfloop collection="#pool[testRunKey].components#" item="componentName">
+ <cftry>
+ <cfset testCase = pool[testRunKey].components[componentName]>
+ <cfset testCase.enableAfterTests()>
+ <cfset testCase.afterTests()>
+
+ <cfcatch>
+ <cflog text="MXUnit afterTests() Exception from Eclipse Remote Facade. Component Name: #componentName#. Error: #cfcatch.message#; #cfcatch.detail#">
+ </cfcatch>
+ </cftry>
+ </cfloop>
+ </cfif>
<cfreturn cache.endTestRun(TestRunKey)>
</cffunction>
@@ -67,7 +86,10 @@
<cfset suite.enableRequestScopeDebugging()>
<cfset actOnTestCase(obj)>
-
+
+ <!--- disable afterTests... we'll run them all during endTestRun --->
+ <cfset obj.disableAfterTests()>
+
<cfif len(methodNames)>
<cfset suite.add(componentName, methodNames, obj)>
<cfelse>
@@ -161,7 +183,7 @@
<!--- --->
<cfloop from="1" to="#ArrayLen(s_test.error.tagcontext)#" index="tag">
<cfif FileExists(s_test.error.tagcontext[tag].template)>
- <cflog text=" #s_test.error.tagcontext[tag].template# #isFrameworkTest# OR NOT #cu.isFrameworkTemplate(s_test.error.tagcontext[tag].template)#" >
+ <!---<cflog text=" #s_test.error.tagcontext[tag].template# #isFrameworkTest# OR NOT #cu.isFrameworkTemplate(s_test.error.tagcontext[tag].template)#" >--->
<cfif isFrameworkTest OR NOT cu.isFrameworkTemplate(s_test.error.tagcontext[tag].template)>
<cfset t.TAGCONTEXT[i] = structNew()>
<cfset t.TAGCONTEXT[i].FILE = s_test.error.tagcontext[tag].template>
View
48 framework/TestCase.cfc
@@ -34,6 +34,34 @@
--->
<cffunction name="tearDown" returntype="void" access="public">
</cffunction>
+
+ <!--- Variables to keep track of before/after runs --->
+ <cfset enableBeforeTests()>
+ <cfset enableAfterTests()>
+
+ <cffunction name="disableBeforeTests" output="false">
+ <cfset variables.beforeTestsEnabled = false>
+ </cffunction>
+
+ <cffunction name="enableBeforeTests" output="false">
+ <cfset variables.beforeTestsEnabled = true>
+ </cffunction>
+
+ <cffunction name="okToRunBeforeTests" output="false" access="public" returntype="boolean" hint="">
+ <cfreturn variables.beforeTestsEnabled>
+ </cffunction>
+
+ <cffunction name="disableAfterTests" output="false">
+ <cfset variables.afterTestsEnabled = false>
+ </cffunction>
+
+ <cffunction name="enableAfterTests" output="false">
+ <cfset variables.afterTestsEnabled = true>
+ </cffunction>
+
+ <cffunction name="okToRunAfterTests" output="false" access="public" returntype="boolean" hint="">
+ <cfreturn variables.afterTestsEnabled>
+ </cffunction>
<!--- constructor --->
<cfset initProperties() />
@@ -109,10 +137,10 @@
<cfargument name="methodName" hint="the name of the method to invoke" type="string" required="Yes">
<cfargument name="args" hint="Optional set of arguments" type="struct" required="No" default="#StructNew()#">
<cfset var output = 0>
- <cfsavecontent variable="output" >
- <cfinvoke component="#this#" method="#arguments.methodName#" argumentcollection="#arguments.args#">
+ <cfsavecontent variable="output" >
+ <cfinvoke component="#this#" method="#arguments.methodName#" argumentcollection="#arguments.args#">
</cfsavecontent>
- <cfreturn output />
+ <cfreturn output />
</cffunction>
<!---
@@ -287,13 +315,13 @@
ignoreIfExisting = false )>
</cffunction>
- <cffunction name="restoreMethod" output="false" access="public" returntype="void" hint="restores a previously overwritten method (via injectMethod) to its original state">
+ <cffunction name="restoreMethod" output="false" access="public" returntype="void" hint="restores a previously overwritten method (via injectMethod) to its original state">
<cfargument name="receiver" type="any" required="true"/>
<cfargument name="functionName" type="string" required="true"/>
<cfset var blender = createObject("component","ComponentBlender")>
<cfset blender._mixinAll(receiver, blender, "_copyToNewName")>
<cfset receiver._copyToNewName(functionName & "__orig__", functionName,false)>
- </cffunction>
+ </cffunction>
<cffunction name="injectProperty" output="false" access="public" returntype="void" hint="injects properties into the receiving object">
@@ -446,7 +474,7 @@
if(StructKeyExists(metadata,"mxunit:" & arguments.annotationName) OR
StructKeyExists(metadata,arguments.annotationName)
)
- {
+ {
break;
}
@@ -500,7 +528,7 @@
<cfset decoratorNames = listPrepend( decoratorNames, getRequiredDecoratorPaths() ) />
<cfloop list="#decoratorNames#" index="decoratorPath">
- <cfset decorator = createObject("component", decoratorPath)/>
+ <cfset decorator = createObject("component", trim(decoratorPath))/>
<cfset decorator.setTarget(object)/>
<cfset decorator.metadata = meta />
<cfset arguments.object = decorator/> <!--- flip it and reverse it. --->
@@ -509,8 +537,8 @@
<cfreturn arguments.object>
</cffunction>
- <cffunction name="getRequiredDecoratorPaths" output="false" access="public" returntype="any" hint="Returns a list of fully-qualified paths to framework-required decorators">
- <cfreturn "mxunit.framework.decorators.DataProviderDecorator">
+ <cffunction name="getRequiredDecoratorPaths" output="false" access="public" returntype="any" hint="Returns a list of fully-qualified paths to framework-required decorators">
+ <cfreturn "mxunit.framework.decorators.DataProviderDecorator">
</cffunction>
<cffunction name="setExpectedExceptionType" access="public">
@@ -532,6 +560,6 @@
</cffunction>
<cffunction name="getVariablesScope" access="public" hint="Front door into the Test's variables scope">
- <cfreturn variables>
+ <cfreturn variables>
</cffunction>
</cfcomponent>
View
18 framework/TestDecorator.cfc
@@ -21,6 +21,24 @@
<cffunction name="afterTests" returntype="void" access="public">
<cfreturn getTarget().afterTests() />
</cffunction>
+
+ <cffunction name="enableBeforeTests" returntype="void" access="public">
+ <cfreturn getTarget().enableBeforeTests() />
+ </cffunction>
+
+ <cffunction name="disableBeforeTests" returntype="void" access="public">
+ <cfreturn getTarget().disableBeforeTests() />
+ </cffunction>
+
+ <cffunction name="enableAfterTests" returntype="void" access="public">
+ <cfreturn getTarget().enableAfterTests() />
+ </cffunction>
+
+ <cffunction name="disableAfterTests" returntype="void" access="public">
+ <cfreturn getTarget().disableAfterTests() />
+ </cffunction>
+
+
<cffunction name="setUp" returntype="void" access="public" hint="">
<cfreturn getTarget().setUp() />
View
10 framework/TestSuiteRunner.cfc
@@ -43,7 +43,10 @@
</cfif>
<!--- Invoke prior to tests. Class-level setUp --->
- <cfset testCase.beforeTests() />
+ <cfif testCase.okToRunBeforeTests()>
+ <cfset testCase.beforeTests() />
+ <cfset testCase.disableBeforeTests()>
+ </cfif>
<cfif len(arguments.testMethod)>
<cfset runTestMethod(testCase, testMethod, results, currentTestSuiteName) />
@@ -54,7 +57,10 @@
</cfif>
<!--- Invoke after tests. Class-level tearDown --->
- <cfset testCase.afterTests()>
+ <cfif testCase.okToRunAfterTests()>
+ <cfset testCase.afterTests() />
+ <cfset testCase.disableAfterTests()>
+ </cfif>
</cfloop>
<cfset results.closeResults() /><!--- Get correct time run for suite --->
View
2 samples/MyComponent.cfc
@@ -8,7 +8,7 @@
</cffunction>
-<cffunction name="append" access="public" returntype="string`">
+<cffunction name="append" access="public" returntype="string">
<cfargument name="val">
<cfreturn "MY VALUE ... " & val >
</cffunction>
View
91 tests/framework/AssertSameTest.cfc
@@ -78,31 +78,72 @@
</cfscript>
</cffunction>
- <cffunction name="testAssertSameArray">
-
- <cfscript>
- try{
- assertSame(ar,ar,"Should catch exception because an array is being passed in");
- }
- catch(mxunit.exception.CannotCompareArrayReferenceException e){
- //no worries
- }
- </cfscript>
-
- </cffunction>
-
- <cffunction name="testAssertNotSameArray">
- <cfscript>
- try{
- assertNotSame(ar,ar2,"Should catch exception because an array is being passed in");
- }
- catch(mxunit.exception.CannotCompareArrayReferenceException e){
- //no worries
- }
- </cfscript>
-
- </cffunction>
-
+ <cffunction name="testAssertSameArray">
+ <cfscript>
+ var local = {};
+
+ if(variables.arraysPassByValue)
+ {
+ local.check = false;
+ try
+ {
+ assertSame(ar,ar,"Should catch exception because an array is being passed in");
+ }
+ catch(mxunit.exception.CannotCompareArrayReferenceException e)
+ {
+ //no worries
+ local.check = true;
+ }
+
+ assertTrue(local.check, "Exception should be thrown");
+ }
+ else
+ {
+ assertSame(arr, arr);
+ }
+
+ //test native arrays
+ local.native = createObject("java", "java.util.ArrayList").init();
+ local.native2 = local.native;
+
+ local.native[1] = "foo";
+
+ assertSame(local.native, local.native2);
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="testAssertNotSameArray">
+ <cfscript>
+ var local = {};
+
+ if(variables.arraysPassByValue)
+ {
+ local.check = false;
+ try
+ {
+ assertSame(ar,ar2,"Should catch exception because an array is being passed in");
+ }
+ catch(mxunit.exception.CannotCompareArrayReferenceException e)
+ {
+ //no worries
+ local.check = true;
+ }
+
+ assertTrue(local.check, "Exception should be thrown");
+ }
+ else
+ {
+ assertNotsame(ar, ar2);
+ }
+
+ local.native = createObject("java", "java.util.ArrayList").init();
+ local.native2 = local.native.clone();
+
+ local.native[1] = "foo";
+
+ assertNotSame(local.native, local.native2);
+ </cfscript>
+ </cffunction>
<cffunction name="testAssertSame">
<cfscript>
View
50 tests/framework/TestCaseBeforeAfterTest.cfc
@@ -0,0 +1,50 @@
+<cfcomponent extends="mxunit.framework.TestCase">
+
+ <cfset beforeTestsCount = 0>
+ <cfset afterTestsCount = 0>
+
+ <cffunction name="beforeTests" output="false" access="public" returntype="any" hint="">
+
+ <cflog text="Before Tests! Count is #beforeTestsCount#">
+ <cfset beforeTestsCount++>
+ </cffunction>
+
+ <cffunction name="afterTests" output="false" access="public" returntype="any" hint="">
+ <cflog text="After Tests! Count is #afterTestsCount#">
+ <cfset afterTestsCount++>
+ </cffunction>
+
+ <cffunction name="setUp" returntype="void" access="public" hint="put things here that you want to run before each test">
+ <cflog text="setUp">
+
+ </cffunction>
+
+ <cffunction name="tearDown" returntype="void" access="public" hint="put things here that you want to run after each test">
+ <cflog text="tearDown">
+
+ </cffunction>
+
+ <cffunction name="one" returntype="void" access="public">
+ <cfset debug("beforeTestsCount is #beforeTestsCount#; afterTestsCount is #afterTestsCount#")>
+ <cfset assertEquals(1, beforeTestsCount)>
+ <cfset assertEquals(0, afterTestsCount)>
+ </cffunction>
+ <cffunction name="two" returntype="void" access="public">
+ <cfset debug("beforeTestsCount is #beforeTestsCount#; afterTestsCount is #afterTestsCount#")>
+ <cfset assertEquals(1, beforeTestsCount)>
+ <cfset assertEquals(0, afterTestsCount)>
+ </cffunction>
+ <cffunction name="three" returntype="void" access="public">
+ <cfset debug("beforeTestsCount is #beforeTestsCount#; afterTestsCount is #afterTestsCount#")>
+ <cfset assertEquals(1, beforeTestsCount)>
+ <cfset assertEquals(0, afterTestsCount)>
+ </cffunction>
+ <cffunction name="four" returntype="void" access="public">
+ <cfset debug("beforeTestsCount is #beforeTestsCount#; afterTestsCount is #afterTestsCount#")>
+ <cfset assertEquals(1, beforeTestsCount)>
+ <cfset assertEquals(0, afterTestsCount)>
+ </cffunction>
+
+
+
+</cfcomponent>
View
2 tests/framework/TestDecoratorTest.cfc
@@ -1,5 +1,5 @@
<cfcomponent extends="mxunit.framework.TestCase" output="false"
- mxunit:decorators="mxunit.tests.framework.fixture.decorators.StoreTestNameDecorator,mxunit.tests.framework.fixture.decorators.IgnoreFunnyFunctionsDecorator">
+ mxunit:decorators="mxunit.tests.framework.fixture.decorators.StoreTestNameDecorator, mxunit.tests.framework.fixture.decorators.IgnoreFunnyFunctionsDecorator">
<cffunction name="testDecoratorWrappingTest" hint="test to see if the decorator gets called and places the name of the test in the request scope"
access="public" returntype="void" output="false">

0 comments on commit 49dd108

Please sign in to comment.