Scriptworks provides a feature for launching test execution from Command Line calls. The core of this process is to provide a call to the Scriptworks-Client component specifying the tests and configurations to execute using curl (or other command line HTTP request tools).
The client requests test information from the Scriptworks cloud server and in turn orchestrates execution of the tests against the appropriate Selenium (what is selenium?) or Appium environment:
The Scriptworks Client App can be local or on a remote machine, and the Selenium/Appium Hub can also be on any machine or a cloud provider like Saucelabs or Bitbar, allowing for total flexibility of architecture.
The curl call can also be invoked by Continuous Integration tools, like Jenkins, Bamboo or TeamCity with test execution output in JUnit format for reporting purposes. Please see appropriate documentation for individual tools.
The Basic call takes the form:
curl -d '{<params>}' -H "Content-Type: application/json" -X POST '<scriptworks-client-url>/ci/runTests/'
An example of a call to a local client to run all tests tagged as 'Regression' using a single target runsetting combination is as follows:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Regression"], "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
The following are basic required parameters, note parameters are case sensitive:
The URL of the Scriptworks server, usually - https://app.scriptworks.io/api (may be a local server for on-premise deployments)
Username of the Scriptworks user usually Email address of the user
Password of the Scriptworks user
The Numeric id of the project, shown in the Id column of the projects table:
The following shows other support parameters:
Alternative to supplying plain text credentials
For specifying Asynchronous (Concurrent) execution. Valid values: true, false (default)
To specify alternative output format for results, useful for execution under CI tools e.g. Jenkins, TeamCity. Valid values: Json (default) or JUnit
To specify that all tests for a given project are to be executed. Valid values: true, false (default). Overrides testIds and tags settings.
An Array specifying which RunSettings should be used for Execution. Can contain one or more numeric values. Found in the Run Settings List through the UI:
An Array specifying any RunSettings groups that should be used for execution. Can contain one or more numeric values.
An Array specifying text of tags used to match tests for execution. Useful as a way of batching tests for execution.
An Array specifying the list of numeric test Ids for execution, Ids are found in the Test List through the UI:
Common scenarios showing examples of parameter combinations are shown in the sections below:
Tests can be specified using their Id, Tags or Run All. Test Information is shown in the Test List table for a given project:
Running an individual test requires specifying the test by id, an example for the project above is shown:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "testIds":[1], "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
Fine control over the individual tests for execution can be achieved by specifying each test in sequence using their individual Id.
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "testIds":[1,18,25], "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
A useful way of grouping tests, a single or set of tags can be executed without the need to specify individual tests:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Register"], "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
This way all tests for a particular area can be tagged, or a Confidence/Smoke pack created and executed.
To simply run all tests, use the runAll parameter:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "runAll": true, "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
Run Settings provide information on target environments, browsers and script parameters, it is possible to configure execution to use one or more Run Settings or Run Settings Groups. Id information can be found in the Run Settings List as shown below:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Register"], "runSettingIds":[1],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Register"], "runSettingIds":[1,3],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Register"], "runSettingsGroupIds":[35],"username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
Run Names are displayed in the Results Dashboard for a given run. When executed through the UI a run name based on Date and Time is generated automatically. When using the CLI features, this can be specified in free text form for filtering purposes:
Specifying a run name is shown below:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "projectId": 2, "tags":["Register"], "runSettingIds":[1],"runName":"Build1.2.3","username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
By default, tests are run in sequence. To specify Asynchronous (concurrent) execution specify the parameter as shown:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "isAsync": true, "projectId": 2, "tags":["Register"], "runSettingIds":[1],"runName":"Build1.2.3","username":"myuser","password":"mypass"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/'
To provide output in JSON or JUnit Format and save this as a file, the combination of outputFormat and the -o parameter to curl can be used:
curl -d '{"apiUrl": "https://app.scriptworks.io/api", "isAsync": true, "projectId": 2, "tags":["Register"], "runSettingIds":[1],"username":"myuser","password":"mypass", "outputFormat": "JUnit"}' -H "Content-Type: application/json" -X POST 'http://127.0.0.1:8081/ci/runTests/' -o Results.xml
This will save the result of the tests in the run in the Results.xml file. This can be picked up by Build Orchestration and CI tools like Jenkins for indicators of Build Health.