Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extremely lightweight testing tool
Message
 
To
15/08/2006 12:01:20
General information
Forum:
Visual FoxPro
Category:
Refactoring and unit testing
Miscellaneous
Thread ID:
01145611
Message ID:
01145773
Views:
20
I am having some issue with the parentheses and not able to compile.

DLC

>I'm trying to buy into Unit Testing, but when I downloaded Fox Unit, I found it to be a lot "heavier" than I wanted to get into. So, I wrote my own testing code. Seeing UT add this category, I figured I'd offer it to the public. No comments yet since I wrote it myself.
>
>
>CLOSE ALL
>CLEAR ALL EXTENDED
>SET CLASSLIB TO (Classlibs)
>SET ESCAPE ON
>SET SAFETY OFF
>SET DEBUGOUT TO Results.txt
>
>UnitTest("TestDemo", "[Parameter]")
>
>SET DEBUGOUT TO
>CLEAR ALL EXTENDED
>CLOSE ALL
>MODIFY COMMAND Results.txt NOWAIT
>
>PROCEDURE UnitTest
>	LPARAMETERS tTestSet
>	LOCAL s
>	TestHarness = CREATEOBJECT("TestHarness")
>	IF PEMSTATUS(TestHarness, LEFT(tTestSet, AT("(",tTestSet)-1), 5)
>		s = SECONDS()
>		TestHarness.&tTestSet
>		DEBUGOUT SECONDS() - s
>	ELSE
>		TestHarness.TestExpr(tTestSet+" Test Not Found", ".F.")
>	ENDIF
>	DEBUGOUT ' '
>	RELEASE TestHarness
>
>DEFINE CLASS TestHarness AS Custom
>PROCEDURE TestExpr
>	LPARAMETERS tMessage, tExpression
>	DEBUGOUT IIF(EVALUATE(tExpression), "Pass   ", "Failed!"), tMessage+":", "["+tExpression+"]"
>PROCEDURE TestRecord
>	LPARAMETERS tAlias, tAllRecords
>	LOCAL tSelect, tScanFor, tRecord, tRecNo
>	LOCAL ARRAY tRecordArray[1,1]
>	tSelect = SELECT(0)
>	SELECT (tAlias)
>	IF RECCOUNT() <> 0
>		tRecNo = RECNO()
>		AFIELDS(tRecordArray, tAlias)
>		tScanFor = IIF(tAllRecords, "", "NEXT 1")
>		SCAN &tScanFor
>			tRecord = ''
>			FOR tLoop = 1 TO ALEN(tRecordArray,1)
>				tRecord = tRecord + TRANSFORM(EVAL(tRecordArray[tLoop,1]))+" "
>			ENDFOR
>			This.TestExpr(tRecord, ".T.")
>		ENDSCAN
>		GOTO tRecNo
>	ELSE
>		This.TestExpr("No Records Found", ".F.")
>	ENDIF
>	SELECT (tSelect)
>PROCEDURE TestFunction
>	LPARAMETERS tFunction, tTest
>	tObject = "This."+LEFT(tFunction, RAT(".",tFunction)-1)
>	IF PEMSTATUS(&tObject, SUBSTR(tFunction, RAT(".",tFunction)+1, RAT("(", tFunction)-RAT(".",tFunction)-1), 5)
>		tRetVal = This.&tFunction
>		tTest = EVL(tTest, ".T.")
>		This.TestExpr(tFunction+": "+TRANSFORM(tRetVal), tTest)
>	ELSE
>		This.TestExpr(tFunction+" Function Not Found", ".F.")
>		tRetVal = .f.
>	ENDIF
>	RETURN tRetVal
>
>PROCEDURE TestDemo
>	LPARAMETERS tParameter
>	This.AddProperty("oDemo", CREATEOBJECT("Demo")
>	This.TestFunction("oDemo.FunctionName()", "Expected Result")
>	This.TestExpr("tParameter", "Expected Result")
>	This.TestRecord("TableName", lAllRecords)
>	This.TestFunction("oDemo.Release()")
>
DLC
"Use the Right Tool for the Job!"
davidandcynthia@email.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform