Configuration File Parameters
Pass parameters to a test using the Configuration File beforeSuite / beforeTest hooks
The Configuration File is a common JS containing all the required parameters to run your test and/or test suite. It includes run hooks which can be used to setup the application backend and define parameters before/after a single test or all tests. Using the Configuration File, you can pass parameters to test runs. The CLI command will pass the parameters to the tests that are included in the run.
Parameter scope
The scope of the defined parameter covers all the tests in a single run (execution).
Defining parameters in a Configuration File
Create a Configuration File that uses the beforeSuite/beforeTest functions inside the Configuration File to define Suite/Test specific parameters. The following example defines the user name
and password
using beforeSuite
and beforeTest
.
exports.config = {
.....
.....
beforeSuite: function (suite) {
console.log("beforeSuite", suite);
return {
"username": "David",
"password": 123
}
},
beforeTest: function (test) {
console.log("beforeTest", test);
return {
"username": "David",
"password": 123
}
}
.....
.....
};
Global exports parameters
In "afterSuite" function you can use exports global parameters exported in your run.
Syntax: suite.exportsGlobal.<param_name>
Using the parameters in the CLI
After defining the Config File, you can pass it to Testim CLI as an argument: -c followed by the file name.
testim -c "testimConfig.js"
At this stage the parameters can be used/called from within the relevant tests using the Step Properties Panel Parameters.
Updated about 1 year ago