API Reference

In the CukeTest Agent runtime interface (running on port 1349 by default), there are currently four manual operation interfaces provided, namely: get version number, run script, stop running script, and query runtime status. These four interfaces are described in detail and explained in the following.

1.Get Version Number

API_get version number Introduction: Get Version Number is the simplest interface that automatically gets and returns the version of CukeTest Agent currently installed on the computer, and is usually used to determine if CukeTest Agent is already installed on the computer.

How to use: This interface sends get requests to the server and does not require any parameters to be passed in.

Run Results: The results are run locally as follows, in the same format as in the response results field, and you can view the version number of CukeTest Agent as 1.0.1.

{
    "app":"CukeTest Agent",
    "version":"1.0.1",
    "ips":["192.168.18.1","192.168.157.1","192.168.1.6"]
}

2.Run Script

Introduction: This is the core of CukeTest Agent's API for running automation scripts remotely. How to use: This API can run scripts remotely, so you need to pass in the parameters of run command, run path and environment variable (optional). The steps to test the effect of running it remotely are as follows.

  1. Open CukeTest to create a demo script, and select the learning demo that comes with CukeTest - math.

CukeTest interface

CukeTest Learning Demo

  1. After creation, copy the path where the project is located to the directory of the requested data, and enter the command cuke --run --format html in cmdLine. The --format html in the command converts the report of the test results into an html file.

Pass in the run command and script path

Run Results: After running the script, a series of results are returned as shown in the Response Results field.

JavaScript
// Run successfully
{"runId": 1, "state": 1, "reason": null} 
// If the run fails it returns the following:
{
    "runId":2,
    "state":2,
    "reason":"TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received 'wrongFile'"
}

See status code description for the meaning of the results (state) returned by the different states.

And the reports folder, where the test reports are stored, is generated in the target directory as follows.

Generated reports folder
Generated local test reports

Note that the runId is used as an identifier for the running process of the script, and each process has a runId, which is needed to query the running status of the script and to stop it.

Environment Variables

You can specify an environment variable object for the project run, and you can use process.env in the script to get all the environment variables (including system environment variables). For example, if you pass an object {anotherEnvField: "This is some addition enviroment"} to the env field in the API call, then you can see the value of process.env in the script as :

JavaScript
{
    ...,
    "anotherEnvField": "This is some addition enviroment",
    ...
}

3. Synchronized Running Scripts

Synchronized running scripts

parameter is equivalent to the run script API, except that it waits for the run to finish before returning.

4. Stop Running Scripts

Stop running scripts

Introduction: This API is used to abort a running script and return the result of the abort. How to use: Enter the runId of the script process that needs to be stopped, such as the process of the math script that just ran, if you enter its runId to abort the process, it will return a "stopped" prompt, which means it has been successfully aborted; if the process has not been created, it will return If the process has not been created, it will return "runNotExists"; if the process is not running normally, it will return an empty string "".

5. Query Operation Status

Query operation status

Introduction: followed by an interface for querying the running status of scripts. It can query what kind of state the target process is in. Instructions: You can query directly by entering the runId of the script process that needs to be queried. Check the following table for the meaning of the results returned for different states.

Status Code Descriptions

State StateName Status Description
0 notStarted Not started
1 succeeded Successful execution
2 failed Failed to run
3 running Running
4 forceStopped Forced stop
5 unknown Unknown

results matching ""

    No results matching ""