siliziumbrain.unittestprovider: Types Modinfo Source  

UnitTestProvider

This module provides a complete unit test environment for code testing.

Types Summary

TTestFailException An exception for tests.
TUnitTestProvider Unit Test Provider class.

Types

Type TTestFailException Extends TException
DescriptionAn exception for tests.
InformationThis exception is thrown everytime a test fails.
Methods Summary
Copy Copies the exception.
NewException Constructor for the exception.
Functions Summary
__NextID Private method. Do not use.
Method Copy:TTestFailException()
DescriptionCopies the exception.
InformationCreates a deep copy of the exception.
returns: A deep copy of the exception.
Method NewException:TTestFailException(psGivenMessage:String)
DescriptionConstructor for the exception.
InformationSets the extern message to psGivenMessage.
Can be used like that: Throw new TNullPointerException.NewException.
Function __NextID:Int()
DescriptionPrivate method. Do not use.
InformationReturns the next ID for a new exception.

Type TUnitTestProvider
DescriptionUnit Test Provider class.
InformationThis class provides a complete unit test environment.
Classes which have test methods can be registered here.
Then the methods will automatically be called by using reflection.
The test results are logged in files.
Constants Summary
CATEGORY , LOGLEVEL
Globals Summary
CurrentTypeID , TypeNameList
Functions Summary
AssertByteAreEqual Checks if two Byte values are equal.
AssertDoubleAreEqual Checks if two Double values are equal.
AssertFalse Checks if an expression is false.
AssertFloatAreEqual Checks if two Float values are equal.
AssertIntAreEqual Checks if two Integer values are equal.
AssertNotNull Checks if an object is not null.
AssertNull Checks if an object is null%.
AssertObjectAreEqual Checks if two Objects are equal.
AssertTObjectAreEqual Checks if two TObjects are equal.
AssertTrue Checks if an expression is true.
AssertTypeAreEqual Checks if the type of two objects is the same.
Fail Just makes the test fail.
SetUpUnitTesting First function to call. Sets up the test environment.
StartUnitTesting This function starts the unit tests.
TestEnd Just logs that a certain method ended.
TestStart Just logs that a certain method started.
Const CATEGORY:String
DescriptionUnitTests have their own category.
Const LOGLEVEL:Int
DescriptionEverything has to be logged. So set the log level to a critical level.
Global CurrentTypeID:TTypeId
DescriptionThe currently used TypeID. (USed for reflection)
Global TypeNameList:TList
DescriptionList with all registered classes.
Function AssertByteAreEqual(pbExpectedValue:Byte, pbActualValue:Byte, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two Byte values are equal.
InformationThis function checks if pbActualValue equals pbExpectedValue.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertDoubleAreEqual(pdExpectedValue:Double, pdActualValue:Double, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two Double values are equal.
InformationThis function checks if pdActualValue equals pdExpectedValue.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertFalse(pbExpression:Byte, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if an expression is false.
InformationThis function checks if pbExpression is false.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertFloatAreEqual(pfExpectedValue:Float, pfActualValue:Float, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two Float values are equal.
InformationThis function checks if pfActualValue equals pfExpectedValue.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertIntAreEqual(piExpectedValue:Int, piActualValue:Int, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two Integer values are equal.
InformationThis function checks if piActualValue equals piExpectedValue.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertNotNull(poObject:Object, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if an object is not null.
InformationThis function checks if poObject is not null.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertNull(poObject:Object, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if an object is null%.
InformationThis function checks if poObject is null.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertObjectAreEqual(poExpectedObject:Object, poActualObject:Object, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two Objects are equal.
InformationThis function checks if poActualObject equals poExpectedObject.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertTObjectAreEqual(ptoExpectedObject:TObject, ptoActualObject:TObject, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if two TObjects are equal.
InformationThis function checks if ptoActualObject equals ptoExpectedObject.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertTrue(pbExpression:Byte, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if an expression is true.
InformationThis function checks if pbExpression is true.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function AssertTypeAreEqual(poExpectedObject:Object, poActualObject:Object, psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionChecks if the type of two objects is the same.
InformationThis function checks if ptoExpectedObject has the same (dynamic) type as ptoActualObject.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function Fail(psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionJust makes the test fail.
InformationUse this function if you want a test to fail.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function SetUpUnitTesting(ptlTypeNames:TList)
DescriptionFirst function to call. Sets up the test environment.
InformationEvery class which has test methods has to be registered here.
Registering a class is simple. The name of every class has to be in ptlTypeNames.
A test method has to begin with 'Test__'. Otherwise it will be ignored. Furthermore, a test method has to have a parameter of the type 'Object'. Attention: The class name has to be the exact name as in your code, because of the reflection.
Function StartUnitTesting(psFileToWriteIn:String)
DescriptionThis function starts the unit tests.
InformationThe test methods of every registered class is invoked here.
Function TestEnd(psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionJust logs that a certain method ended.
InformationThis function can be called when a test method ends. Just makes the log files nicer.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.
Function TestStart(psTestName:String, psComesFromFile:String, psFileToWriteIn:String)
DescriptionJust logs that a certain method started.
InformationThis function can be called when a test method starts. Just makes the log files nicer.
psTestName is the name of the method which calls this function.
psComesFromFile is the filename where the test method is in.
psFileToWriteIn is the path to the file where the log should be written in.

Module Information

Versionv1.00
AuthorM0rgenstern - Siliziumbrain - Kevin Peter Hoffeld
LicensePublic Domain
History v1.0015 July 2012 - Final Release