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

fcf.test() function

fcf.test(string a_part, string a_group, string a_name, function a_cbtest)
fcf.test(string a_group, string a_name, function a_cbtest)
fcf.test(string a_name, function a_cbtest)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Declares a unit test.

It is analogous to the fcf.NUnitest.Unitest.add() method, but performs automatic loading of the fcf-framework-unitest module, both on the browser side and on the server side.

On the browser side, the loading of the fcf-framework-unitest module is performed only if the page is loaded by the fcf.NUnitest.Unitest.run() method from the NODEJS server side or the ___fcf_unitest GET request URL argument is declared.

Arguments

string a_part = "default"
- Part of the test

string a_group = "default"
- Group of the test

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"); fcf.test("Some test", (a_unitest)=>{ a_unitest.equal(1, 2); }); unitest.run() .finally(()=>{ process.exit(0); });

Output:

2023-05-10 16:19:54.825 [PID:163495] [LOG] [MOD:UniTest]: ==================================================== 2023-05-10 16:19:54.830 [PID:163495] [LOG] [MOD:UniTest]: Start testing on the server side... 2023-05-10 16:19:54.831 [PID:163495] [LOG] [MOD:UniTest]: Parts: * 2023-05-10 16:19:54.831 [PID:163495] [LOG] [MOD:UniTest]: Groups: * 2023-05-10 16:19:54.832 [PID:163495] [LOG] [MOD:UniTest]: Tests: * 2023-05-10 16:19:54.833 [PID:163495] [LOG] [MOD:UniTest]: 2023-05-10 16:19:54.833 [PID:163495] [LOG] [MOD:UniTest]: Start local tests... 2023-05-10 16:19:54.833 [PID:163495] [LOG] [MOD:UniTest]: -------------------- 2023-05-10 16:19:54.834 [PID:163495] [LOG] [MOD:UniTest]: Test [default][default][Some test] running ... 2023-05-10 16:19:54.838 [PID:163495] [LOG] [MOD:UniTest]: Test [default][default][Some test] is failed. Position: /home/user/project/index.js:5 Error: "1" and "2" are not equal Stack: Namespace.Unitest.compare (/home/user/project/node_modules/fcf-framework-unitest/unitest.js:205:19) Namespace.Unitest.equal (/home/user/project/node_modules/fcf-framework-unitest/unitest.js:244:21) Object.test (/home/user/project/index.js:5:13) Actions. (/home/user/project/node_modules/fcf-framework-unitest/unitest.js:612:26) Actions._execute (/home/user/project/node_modules/fcf-framework-core/fcf.js:3149:24) Actions.then (/home/user/project/node_modules/fcf-framework-core/fcf.js:2595:16) Namespace.Unitest._runLocalTests (/home/user/project/node_modules/fcf-framework-unitest/unitest.js:608:14) Actions. (/home/user/project/node_modules/fcf-framework-unitest/unitest.js:529:25) Actions._execute (/home/user/project/node_modules/fcf-framework-core/fcf.js:3154:24) Object.complete (/home/user/project/node_modules/fcf-framework-core/fcf.js:3113:18) 2023-05-10 16:19:54.839 [PID:163495] [LOG] [MOD:UniTest]: 2023-05-10 16:19:54.839 [PID:163495] [LOG] [MOD:UniTest]: ---------------------------------------------------- 2023-05-10 16:19:54.840 [PID:163495] [LOG] [MOD:UniTest]: 1 test have been completed. 2023-05-10 16:19:54.840 [PID:163495] [LOG] [MOD:UniTest]: Errors: 1; Successfully: 0; Total: 1 2023-05-10 16:19:54.840 [PID:163495] [LOG] [MOD:UniTest]: Tests that failed: Executor server: [default][default][Some test]