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

run() method from fcf.NUnitest.Unitest class

fcf.Actions->object run()
fcf.Actions->object run(object a_options)

Package: fcf-framework-unitest

File: fcf-framework-unitest:unitest.js

Available from version: 1.0.1

Runs tests, both on the server side and on the browser side

Arguments

object a_options = undefined
- An object containing test execution options
  • [string]|string parts = undefined - The name of the section(s) of the tests to run. 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. If the parameter is undefined, then no restriction is applied.

  • [string]|string groups = undefined - The name of the group(s) of tests to run. If the parameter is undefined, then no restriction is applied.

  • [string]|string tests = undefined - Name is a list of test names to be run. If the parameter is undefined, then no restriction is applied.

  • boolean enableWebTests = true - Flag to allow browser side tests to run when running on the NODEJS server side. Browser-side testing (when run from a NODEJS script) will only run if the webTestingPages array is not empty and enableWebTests is set to true.

  • boolean enableLocalTests = true - A flag that allows tests to run on the caller.

  • [string] include = [] - An array of included JS files during testing. File paths are specified in FCF notation.

  • boolean quiet = false - If equal to true, then the output to the console of information about testing is not performed

  • integer timeout = 30000 - The time to wait for a single test to run, in milliseconds.

  • [object] processes = [] - An array describing the processes that will run before testing. When testing is complete, the processes are terminated.

    Object properties:

    • string|[string] command - The command to start the process can be given as a single string or as an array of command line arguments.

    • integer startTimeout = 1000 - Time in milliseconds to wait for the application to start. The executable script transfers control to the following commands only after the specified delay has elapsed.

  • [object] webProcesses = [] - An array describing the processes that will run before testing on the browser side. Used to start WEB services. Runs only if the enableWebTests parameter is set to true and the webTestingPages array is not empty. When testing is complete, the processes are terminated.

    Object properties:

    • string|[string] command - The start command, which can be given as a single string or an array of command line arguments.

    • integer startTimeout = 1000 - Time in milliseconds to wait for the application to start. The executable script transfers control to the following commands only after the specified delay has elapsed.

  • [string|[string]] webBrowsers = [["google-chrome", "chrome", "chromium", "firefox", "opera", "safari"]] - An array with a list of browsers for which testing will be carried out. If the array element is an array, then the test will run against the first browser in the nested array that runs successfully.

    The value of the array element is the name of the command to be executed, so the path to the specified browser must be specified in the PATH environment variable. This is especially important on Windows!

  • [object] webTestingPages = [] - An array with information about the pages for which testing will be carried out on the browser side

    Object properties:

    • string url - URL of the page being tested

    • [string] include = [] - An array of additionally included URLs to JS files on the browser side, where tests can be located.

    • integer|string wait = 0 - Waiting time before testing, after page load. If the parameter is a string, then it must contain the path to a global asynchronous function that will return control after all page components have been loaded.

  • integer webTestingPort = 4589 - TCP port for sending internal testing commands on the browser side

  • function onMessage = undefined - Callback handler function on the event of information output to the console

    Function signature: onMessage(object a_info)

    • object a_info - An object with information about output to the console

      • string part - The name of the test section currently running

      • string group - The name of the test group that is currently running

      • string test - Name of the current test

      • string level - Logging level ("test"|"crash"|"error"|"warning"|"log"|"info"|"debug"|"trace")

      • string source - The name of the module from which the logging was performed

      • string executor - Test executor. If the test was run on the server, then the value is "server", if the test was run on the browser side, then the value is equal to the name of the browser process.

      • Date time - Logging time.

Result
fcf.Actions->object
- Returns an object with information about testing in the delayed action

Object properties:

  • integer errorCount - Number of tests executed with errors

  • integer testCount - Number of tests performed

  • integer successfulCount - Number of successfully completed tests

  • [object] tests - Array with information about executed tests

    Object properties:

    • string part - Test section name

    • string group - Test group name

    • string test - Test name

    • string executor - Test executor. If the test was run on the server, then the value is "server", if the test was run on the browser side, then the value is equal to the name of the browser process

    • string status - Test completion status ("error"|"ok")

    • Error error = undefined - Error object with which the test ended

  • [object] output - An array with information about output to the console. For a description of the object's elements, see the description of the onMessage parameter.

Example: Function application

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

Output:

2023-05-09 22:34:52.920 [PID:138127] [LOG] [MOD:UniTest]: ==================================================== 2023-05-09 22:34:52.925 [PID:138127] [LOG] [MOD:UniTest]: Start testing on the server side... 2023-05-09 22:34:52.925 [PID:138127] [LOG] [MOD:UniTest]: Parts: * 2023-05-09 22:34:52.926 [PID:138127] [LOG] [MOD:UniTest]: Groups: * 2023-05-09 22:34:52.926 [PID:138127] [LOG] [MOD:UniTest]: Tests: * 2023-05-09 22:34:52.927 [PID:138127] [LOG] [MOD:UniTest]: 2023-05-09 22:34:52.927 [PID:138127] [LOG] [MOD:UniTest]: Start local tests... 2023-05-09 22:34:52.928 [PID:138127] [LOG] [MOD:UniTest]: -------------------- 2023-05-09 22:34:52.928 [PID:138127] [LOG] [MOD:UniTest]: Test [default][default][Some test] running ... 2023-05-09 22:34:52.929 [PID:138127] [LOG] [MOD:UniTest]: Test [default][default][Some test] is completed. 2023-05-09 22:34:52.930 [PID:138127] [LOG] [MOD:UniTest]: 2023-05-09 22:34:52.930 [PID:138127] [LOG] [MOD:UniTest]: ---------------------------------------------------- 2023-05-09 22:34:52.931 [PID:138127] [LOG] [MOD:UniTest]: 1 test have been completed. 2023-05-09 22:34:52.931 [PID:138127] [LOG] [MOD:UniTest]: Errors: 0; Successfully: 1; Total: 1