-
Notifications
You must be signed in to change notification settings - Fork 4
6. AJ_UnitTest Class
Since the 4D version 18 R3, it is possible to use classes inside 4D.
The AJ_UnitTest
class is exposed and can be used to replace the New AJ_Tools_UT_describe
method.
describe : (text) description of the test.
method : (text) method that execute the test (must be "Current method name").
category : (text) (optional) category of the test. This is used to separate multiple tests in different categories.
return a unit test object with the assert member function. This object will need 4 parameters (given, should, expected, actual) before to call the assert method.
Create a new test. A test can then do multiple assert. Only one test must be created by method.
// __UNIT_TEST
$test:=AJ_UnitTest .new("Sum()";Current method name;"Math")
$test.given:="no parameters"
$test.should:="return 0"
$test.expected:=0
$test.actual:=zz_sum
$test.assert()
$test.given:="1 parameter (here 5)"
$test.should:="return 10 (addition itself)"
$test.expected:=10
$test.actual:=zz_sum (5)
$test.assert()
$test.given:="3 and 3"
$test.should:="return 6"
$test.expected:=6
$test.actual:=zz_sum (3;3)
$test.assert()
(Available since v2.0.0 of the component)
AJ_Tools_UnitTest 1.0.0 - Thursday, 04 June 2020
User Manual 🇺🇸
-
Introduction
-
Practice
Manuel d'utilisation 🇫🇷
-
Introduction
-
Pratique