Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extremely lightweight testing tool
Message
 
À
15/08/2006 12:01:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Refactorisation et unité d'essai
Divers
Thread ID:
01145611
Message ID:
01145620
Vues:
22
Why not place this code in FAQ or in Download section?
Here, i forum, after a while we all will lost the link about it.


>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()")
>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform