mn8 Language Reference | Index    

TestCase

SUMMARY: NO ATTRIBUTES  ELEMENTS SUMMARY  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  ELEMENT DETAILS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

A test case defines the fixture to run multiple tests.
To define a test case

Usage

Each test runs in its own fixture so there can be no side effects among test runs. Here is an example:

            define MathTest extends TestCase [
                fValue1 typeof Real
                fValue2 typeof Real

                : create ( $name typeof String ) [
                    super.create($name)]

                : setUp() [
                    /fValue1= 2.0
                    /fValue2= 3.0]]

For each test implement a method which interacts with the fixture. Verify the expected results with assertions specified by calling assert with a boolean.

            : testAdd [
                result= fValue1 + fValue2
                return .assertTrue(result == 5.0)] typeof String

The tests to be run can be collected into a TestSuite. mn8Unit provides different test runners which can run a test suite and collect the results. A test runner either expects a static method suite as the entry point to get a test to run or it will extract the suite automatically.

            static : suite [
                $suite typeof TestSuite( "Infos from this suite" )
                $mathTest typeof MathTest
                suite.addTest( $mathTest );
                return $suite;]

Version: 0.1
Authors:Antal Attila ()
Location:
Inherits: Concept, Assert, Test
Inherited by: TestCaseAdapterWarning

Element List

 fName TYPEOF String LABEL "fName"
top

Constructor List

create (String $name)
create
top

Method List

IntegercountTestCases
TestResultcreateResult
Stringname
TestResultrun
run (TestResult $result)
StringrunBare
StringrunTest
setName (String $name)
setUp
tearDown
StringtoString
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI
Methods inherited from: Assert
assertEquals, assertEquals, assertNil, assertNil, assertNotNil, assertNotNil, assertTrue, assertTrue, fail, fail, failNotEquals
Methods inherited from: Test
countTestCases, run

Detailed Element Info

fName

Label:fName
Type:String
Is Static:false
Is Hidden:false
Is Multi:false
Show Empty:true

This element hold a name of the test case

top

Detailed Constructor Info

create (String $name)
Parameters:
$name :The name of test case

Constructs a test case with the given name.

top
create

Constructs a test case without name.

top

Detailed Method Info

countTestCases
Returns: Integer

Counts the number of test cases executed by run($result typeof TestResult).

top
createResult
Returns: TestResult

Creates a default TestResult concept

top
name
Returns: String

Gets the name of a TestCase

top
run
Returns: TestResult

A convenience method to run this test, collecting the results with a default TestResult concept.

top
run (TestResult $result)
Parameters:
$result :
Returns:

Runs the test case and collects the results in TestResult.

top
runBare
Returns: String

Runs the bare test sequence.

top
runTest
Returns: String

Override to run the test and assert its state. Returns the assert fail message.

top
setName (String $name)
Parameters:
$name :Test Case name
Returns:

Sets the name of a TestCase

top
setUp
Returns:

Sets up the fixture, for example, open a network connection.

top
tearDown
Returns:

Tears down the fixture, for example, close a network connection.

top
toString
Returns: String

Returns a string representation of the test case

top