FCF 2.0 development in progress...
> > > > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

add() method from fcf.NUnitest.Unitest class

add(string a_part, string a_group, string a_name, function a_cbtest)
add(string a_group, string a_name, function a_cbtest)
add(string a_name, function a_cbtest)

Package: fcf-framework-unitest

File: fcf-framework-unitest:unitest.js

Available from version: 1.0.1

Registers a test

Instead of the add() method, it is recommended to use the fcf.test() function to add a test, which automatically loads the fcf-framework-unitest:unitest.js module


string a_part = "default"
- The name of the test part. The testing section allows you to separate tests, for example, into basic tests that do not require the application to run, and application tests that require the entire application to run.

string a_group = "default"
- Test group name

string a_name
- Test name

function a_cbtest
- Test function

Function signature: [simple or async] a_cbtest(fcf.NUnitest.Unitest a_unitest)

fcf.NUnitest.Unitest a_unitest - The test object created by the main object on which the run() method was called. It is on this object that the verification methods are called during script execution.

Example: Function application

let fcf = require("fcf-framework-core"); let unitest = require("fcf-framework-unitest"); function testedFunction(){ return 1; } unitest.add("Some test", (a_unitest)=>{ a_unitest.equal(testedFunction(), 1); }); unitest.run() .finally(()=>{ process.exit(0); });


2023-05-08 05:18:09.699 [PID:83750] [LOG] [MOD:UniTest]: ==================================================== 2023-05-08 05:18:09.704 [PID:83750] [LOG] [MOD:UniTest]: Start testing on the server side... 2023-05-08 05:18:09.705 [PID:83750] [LOG] [MOD:UniTest]: Parts: * 2023-05-08 05:18:09.706 [PID:83750] [LOG] [MOD:UniTest]: Groups: * 2023-05-08 05:18:09.706 [PID:83750] [LOG] [MOD:UniTest]: Tests: * 2023-05-08 05:18:09.707 [PID:83750] [LOG] [MOD:UniTest]: 2023-05-08 05:18:09.707 [PID:83750] [LOG] [MOD:UniTest]: Start local tests... 2023-05-08 05:18:09.708 [PID:83750] [LOG] [MOD:UniTest]: -------------------- 2023-05-08 05:18:09.708 [PID:83750] [LOG] [MOD:UniTest]: Test [default][default][Some test] running ... 2023-05-08 05:18:09.709 [PID:83750] [LOG] [MOD:UniTest]: Test [default][default][Some test] is completed. 2023-05-08 05:18:09.710 [PID:83750] [LOG] [MOD:UniTest]: 2023-05-08 05:18:09.710 [PID:83750] [LOG] [MOD:UniTest]: ---------------------------------------------------- 2023-05-08 05:18:09.711 [PID:83750] [LOG] [MOD:UniTest]: 1 test have been completed. 2023-05-08 05:18:09.711 [PID:83750] [LOG] [MOD:UniTest]: Errors: 0; Successfully: 1; Total: 1