• 沒有找到結果。

Testing Flows from the CLI

在文檔中 TIBCO Flogo® Enterprise User's Guide (頁 140-144)

This feature allows you to test your Flogo app using the Flogo app itself. Once you have built the binary for a Flogo app, you can test it using the test command. This feature is also useful to automate the testing process for a flow.

You can do the following from the CLI:

List all flows in a specified app

Generate test data for a given flow

Test a flow against test data you specify in a JSON file

Test a flow against test data you specify in a JSON file and generate the output of the test in an output file that you specify

Prerequisites

This feature is supported on Flogo Enterprise version 2.3 on greater.

The app binary must have been generated in Flogo Enterprise version 2.3 on greater using either the Flogo Enterprise Web UI or the CLI.

The app binary must be readily accessible on the machine from which you plan to test it.

Follow these steps to get help on the test command:

Procedure

1. Open a command prompt or terminal window depending on your platform.

2. Navigate to the folder where you stored the app binary.

3. Run the following command to get the online help on the test command:

On Windows: <app-binary> -test

On Macintosh: ./<app-binary> -test

On Linux: ./<app-binary> -test

This command outputs the usage for the test command along with some examples. Refer to test Command for details.

4. Run the command with the appropriate option to test your app. For example, if your app binary name is MyTestApp-darwin-amd64, to get the names of the flows in your app, run: ./MyTestApp-darwin-amd64 -test -flows

The output of the command lists all the flows in the app.

Using the test command to test your flow from the CLI To test a flow, follow these steps:

Procedure

1. Generate the input JSON file using the -flowdata option with the command as described above (./

<app_binary> -test -flowdata <flow_name>). This will generate a JSON file ( <app-name>_<flow-name>_input.json) with the input fields that you specified when creating the flow in the Input tab of the Flow Inputs & Outputs tab of the blank flow.

For flows created with a trigger, this file will always be empty.

You can also use the test configurations that were exported from Lauch Configuration as the input file instead of generating the input file with the -flowdata option.

2. Modify the generated file, <app-name>_<flow-name>_input.json, from step 1 to set specific values for the input fields in the file.

3. Use the <app-name>_<flow-name>_input.json file to test your flow:

./<app_binary> -test -flowin <app-name>_<flow-name>_input.json -flowout <output>.json

For example, if your app name is MyTestApp and the input file generated by -flowin is

MyTestApp_MyFlow_input.json and the output file you specify for -flowout is MyOutput.json, the command will look as follows:

./MyTestApp -test -flowin MyTestApp_MyFlow_input.json -flowout MyOutput.json

The test Command

Use the test command in Flogo Enterprise to test your Flogo app. This feature is available in Flogo Enterprise 2.3.0 or greater.

Options Description and Example

-flows

SYNTAX:

./<binary_filename> -test -flows

Lists all flows in the specified <binary_filename> app.

Example:

./MyTestApp -test -flows

where MyTestApp is the app binary.

-flowdata

SYNTAX:

./<binary_filename> -test -flowdata

<flow-name>

Generates input fields data file for a given flow. For blank flows, the input test data is generated based on the Flow Inputs you provided when creating the flow (in the Input tab of the Flow Inputs & Outputs accordion tab of the blank flow).

For flows created with a trigger input, the input values in the generated file will always be empty.

Example:

./MyTestApp -test -flowdata TestFlow

where MyTestApp is the app binary and TestFlow is a flow within MyTestApp. A JSON file with the file name with format <app-name>_<flow-name>_input.json

gets created. This file contains the generted input fields configured in the Input tab of the Flow Inputs &

Outputs accordion tab of the blank flow.

You can edit this file to set specific values for the input fields and use the file to test your flow using the

-flowin option described below.

-flowin

SYNTAX:

./<binary_filename> -test -flowin

<path-to-input-file>

Test flow against given test data contained in an input JSON file. This file must exist in the location that you specify in the command.

Example:

./MyTestApp -test -flowin /usr/

TestFlow_input.json

where MyTestApp is the app binary and /usr/

TestFlow_input.json is the path to the JSON file containing the input to the flow.

You can also use the test configurations that were exported from Launch Configuration as the input file in this command.

Options Description and Example

-flowout

SYNTAX:

./<binary_filename> -test -flowout

<path-to-output-file-name>

Write flow output (if applicable) to the specified file. If a file with the specified name does not already exist in the specified location, Flogo Enterprise will create the file. If you do not specify a file name, the output gets printed to the console.

Example:

./MyTestApp -test -flowin TestFlow_input.json -flowout TestFlow_output.json

where MyTestApp is the app binary,

TestFlow_input.json is the file containing the input data to the flow and TestFlow_output.json is the path to the JSON file you specify to hold the output from the flow.

在文檔中 TIBCO Flogo® Enterprise User's Guide (頁 140-144)