Skip to content

Testing

Assertion utilities: equal, contains, length, true, not null, greater than.

6 modules

ModuleDescription
ยืนยันมีค่ายืนยันว่าคอลเลกชันมีค่า
ยืนยันเท่ากันยืนยันว่าสองค่าเท่ากัน
ยืนยันมากกว่ายืนยันว่าค่ามากกว่าค่าอื่น
ยืนยันความยาวยืนยันว่าคอลเลกชันมีความยาวที่คาดหวัง
ยืนยันไม่ใช่ Nullยืนยันว่าค่าไม่ใช่ null หรือ undefined
ยืนยันจริงยืนยันว่าเงื่อนไขเป็นจริง

Modules

ยืนยันมีค่า

test.assert_contains

ยืนยันว่าคอลเลกชันมีค่า

Parameters:

NameTypeRequiredDefaultDescription
collection['array', 'string']Yes-คอลเลกชันที่จะค้นหา
value['string', 'number', 'boolean']Yes-คอลเลกชันที่จะค้นหา
messagestringNo-ค่าที่จะค้นหา

Output:

FieldTypeDescription
passedbooleanข้อความข้อผิดพลาดที่กำหนดเอง
collection['array', 'string']การยืนยันผ่านหรือไม่
value['string', 'number', 'boolean']ยืนยันว่าคอลเลกชันมีค่า
messagestringยืนยันว่าคอลเลกชันมีค่า

ยืนยันเท่ากัน

test.assert_equal

ยืนยันว่าสองค่าเท่ากัน

Parameters:

NameTypeRequiredDefaultDescription
actual['string', 'number', 'boolean', 'object', 'array']Yes-ค่าจริง
expected['string', 'number', 'boolean', 'object', 'array']Yes-ค่าจริง
messagestringNo-ค่าที่คาดหวัง

Output:

FieldTypeDescription
passedbooleanข้อความข้อผิดพลาดที่กำหนดเอง
actual['string', 'number', 'boolean', 'object', 'array']การยืนยันผ่านหรือไม่
expected['string', 'number', 'boolean', 'object', 'array']ยืนยันว่าสองค่าเท่ากัน
messagestringยืนยันว่าสองค่าเท่ากัน

ยืนยันมากกว่า

test.assert_greater_than

ยืนยันว่าค่ามากกว่าค่าอื่น

Parameters:

NameTypeRequiredDefaultDescription
actualnumberYes-ค่าจริง
thresholdnumberYes-ค่าจริง
messagestringNo-ค่าเกณฑ์

Output:

FieldTypeDescription
passedbooleanข้อความข้อผิดพลาดที่กำหนดเอง
actualnumberการยืนยันผ่านหรือไม่
thresholdnumberยืนยันว่าค่ามากกว่าค่าอื่น
messagestringยืนยันว่าค่ามากกว่าค่าอื่น

ยืนยันความยาว

test.assert_length

ยืนยันว่าคอลเลกชันมีความยาวที่คาดหวัง

Parameters:

NameTypeRequiredDefaultDescription
collection['array', 'string']Yes-คอลเลกชันที่จะตรวจสอบ
expected_lengthnumberYes-คอลเลกชันที่จะตรวจสอบ
messagestringNo-ความยาวที่คาดหวัง

Output:

FieldTypeDescription
passedbooleanข้อความข้อผิดพลาดที่กำหนดเอง
actual_lengthnumberข้อความข้อผิดพลาดที่กำหนดเอง
expected_lengthnumberยืนยันว่าคอลเลกชันมีความยาวที่คาดหวัง
messagestringยืนยันว่าคอลเลกชันมีความยาวที่คาดหวัง

ยืนยันไม่ใช่ Null

test.assert_not_null

ยืนยันว่าค่าไม่ใช่ null หรือ undefined

Parameters:

NameTypeRequiredDefaultDescription
value['string', 'number', 'boolean', 'object', 'array', 'null']Yes-ค่าที่จะตรวจสอบ
messagestringNo-ค่าที่จะตรวจสอบ

Output:

FieldTypeDescription
passedbooleanยืนยันว่าค่าไม่ใช่ null หรือ undefined
messagestringยืนยันว่าค่าไม่ใช่ null หรือ undefined

ยืนยันจริง

test.assert_true

ยืนยันว่าเงื่อนไขเป็นจริง

Parameters:

NameTypeRequiredDefaultDescription
conditionbooleanYes-เงื่อนไขที่จะตรวจสอบ
messagestringNo-เงื่อนไขที่จะตรวจสอบ

Output:

FieldTypeDescription
passedbooleanยืนยันว่าเงื่อนไขเป็นจริง
messagestringยืนยันว่าเงื่อนไขเป็นจริง

Released under the Apache 2.0 License.