3.8.1 • Published 26 days ago

@testwizard/core v3.8.1

Weekly downloads
1
License
See readme.md
Repository
-
Last release
26 days ago

Testwizard - Core

Javascript language support for testing different kinds of devices using testwizard

npm (scoped) lerna

Usage

Use this package in combination with one (or more) of the specific device packages

Sidecar file

The testwizard manager enables a single script to be run on different devices with (optionally) different sets of parameters. To enable this from any IDE a sidecar file (in json format) is used . By default the name of the sidecar file is the same as this script, but with a .json extension. A command-line-argument (--sidecar or -s) can be used to instruct the usage of a different file.

This json file has the following attributes:

  • tester: The name of the tester (optional)
  • parameters: An array of parameters (optional)
    • name: The name of the parameter
    • value: The value for the parameter
  • resources: An array of resources
    • category: The category of the testobject
    • name: The name of the testobject
    • id: The id of the testobject
  • outputFolder: The folder where the log files should be written (optional)

Parameters

Every parameter will be made available as a field of the session object.

console.log("param1 = " + session.param1);

Resources

All resources will be acquired (and thus locked) at the start of a test run and will be released when the script ends. To execute a command on a testobject it must be referenced (constructed), when doing this, the name of the resource will be used, while the id corresponds to the actual device.

const mobile = new Mobile(session, "Mobile");
let result = mobile.initDriver();

Output folder

When running a test all actions are logged (testrun.log) and so is the result (result.log). By default the location of these files is a timestamp based folder within the runs folder. If a different location is preferred, this can be configured in the outputfolder attribute.

Session

When the script is executed (run or debug), a new session is created, and all resources will be locked If any of the resources is allready in use, a session cannot be setup and an error will be thrown. The session is destroyed when the script ends. At this point the resources will be released and available for other script runs.

More information about the session can be read from the info attribute:

  • info
    • scriptFilePath: The full path of the script file
    • scriptFileName: The file name of the script file
    • storagePath: The directory where the output will be written
    • tester: The name of the tester
  • info.environment
    • scriptsBasePath: The root directory where all scripts are stored
    • storageBasePath: The root directory where the output is written
    • ocrEngine: The name of the ocr engine being used
    • testWizardVersion: The version of testwizard being used
  • info.session (optional: only when run from within the manager)
    • id: The unique identifier of the session in the manager
    • name: The name of the session
    • scriptIndex: The index of the script within the session

Results

The outcome of a script run can be either Pass, Fail or Error. During a script run multiple results can be reported, this can be done in 2 different ways: 1. addPass / addFail: reports a pass or fail but does not post it to the server 1. setResult: reports a pass / fail /error and posts it to the server

let result = mobile.initDriver();
if (result.success)
     session.addPass(result.message);
else
     session.addFail(result.message);
let result = mobile.initDriver();
if (result.success)
     session.setResult(Testwizard.ResultCodes.PASS, result.message);
else
     session.setResult(Testwizard.ResultCodes.FAIL, result.message);

Sample script

javascript (sample.js)

'use strict';

const Testwizard = require("@testwizard/core");
const Mobile = require("@testwizard/mobile");
const SetTopBox = require("@testwizard/set-top-box");

const session = Testwizard.Session;

console.log("Parameters:");
console.log("  param1 = " + session.param1);
console.log("  param2 = " + session.param2);

console.log("Session info:");
console.log("  info.scriptFilePath = " + session.info.scriptFilePath);
console.log("  info.scriptFileName = " + session.info.scriptFileName);
console.log("  info.storagePath = " + session.info.storagePath);
console.log("  info.tester = " + session.info.tester);
console.log("  info.environment.scriptsBasePath = " + session.info.environment.scriptsBasePath);
console.log("  info.environment.storageBasePath = " + session.info.environment.storageBasePath);
console.log("  info.environment.ocrEngine = " + session.info.environment.ocrEngine);
console.log("  info.environment.testWizardVersion = " + session.info.environment.testWizardVersion);
if (session.info.session !== null)
{
    console.log("Script was started by the manager:");
    console.log("  info.session.id = " + session.info.session.id);
    console.log("  info.session.name = " + session.info.session.name);
    console.log("  info.session.scriptIndex = " + session.info.session.scriptIndex);
}

const mobile = new Mobile(session, "Mobile");

console.log("mobile: initDriver");
let result = mobile.initDriver();
console.log(result.message);
if (!result.success)
     session.addFail(result.message);

const setTopBox = new SetTopBox(session, "STB");

console.log("stb: sendRCKey");
result = setTopBox.sendRCKey("menu");
console.log(result.message);
if (!result.success)
     session.addFail(result.message);

if (!(session.hasFails() || session.hasErrors()))
    session.addPass("Test was successful");

sidecar file (sample.json)

{
    "tester": "Some tester",
    "parameters": [
        { "name": "param1", "value": "value1"},
        { "name": "param2", "value": "value2"}
    ],
    "resources": [
        { "category": "MOBILE", "name": "Mobile", "id": "Mobile 1"},
        { "category": "STB", "name": "STB", "id": "SetTopBox 1"}
    ],
    "outputFolder": "c:\\temp"
}

Compatibility

The version is compatible with testwizard version 3.1

License

Testwizard licensing

3.8.1

26 days ago

3.8.1-build4811

2 months ago

3.8.1-build4748

2 months ago

3.8.0-build4147

7 months ago

3.8.0-build3792

10 months ago

3.8.0-build3346

1 year ago

3.8.0-build3353

1 year ago

3.7.1-build3265

1 year ago

3.7.1

1 year ago

3.7.0-build3259

1 year ago

3.7.0

1 year ago

3.7.0-build2811

2 years ago

3.7.0-build2859

1 year ago

3.7.0-build2815

2 years ago

3.7.0-build2255

2 years ago

3.7.0-build1715

2 years ago

3.6.0

2 years ago

3.7.0-build1651

2 years ago

3.6.0-build1300

2 years ago

3.6.0-build1261

2 years ago

3.6.0-build1262

2 years ago

3.5.0-build1260

2 years ago

3.5.0

2 years ago

3.5.0-build1249

3 years ago

3.5.0-build1191

3 years ago

3.5.0-build1071

3 years ago

3.4.5

3 years ago

3.5.0-build1061

3 years ago

3.4.4-build1044

3 years ago

3.4.4-build1033

3 years ago

3.4.4-build931

3 years ago

3.4.4-build927

3 years ago

3.4.4-build919

3 years ago

3.4.4

3 years ago

3.3.13

3 years ago

3.3.14

3 years ago

3.3.10

3 years ago

3.3.11

3 years ago

3.3.12

3 years ago

3.4.0-alpha.0

3 years ago

3.3.9

3 years ago

3.3.8

3 years ago

3.3.7

3 years ago

3.3.6

3 years ago

3.4.3

3 years ago

3.3.5

3 years ago

3.3.4

3 years ago

3.3.1

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.0

3 years ago

3.2.10

3 years ago

3.2.9

3 years ago

3.2.8

3 years ago

3.2.7

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3

4 years ago

3.4.2

4 years ago

3.4.1

4 years ago

3.4.0

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.19

4 years ago

3.1.18

4 years ago

3.1.17

4 years ago

3.1.16

4 years ago

3.1.15

5 years ago

3.1.14

5 years ago

3.1.13

5 years ago

3.1.12

5 years ago

3.1.11

5 years ago

3.1.10

5 years ago

3.1.9

5 years ago

3.1.8

5 years ago

3.1.7

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.1-alpha.7

5 years ago

1.0.1-alpha.6

5 years ago

1.0.1-alpha.5

5 years ago

1.0.1-alpha.4

5 years ago

1.0.1-alpha.3

5 years ago

1.0.1-alpha.2

5 years ago

1.0.1-alpha.1

5 years ago

1.0.1-alpha.0

5 years ago