Playing a Test Case Once

After you design a flow, you can test it by playing it once.

When designing a flow, runtime errors can go undetected until you build the app to execute the flow. It can be cumbersome to test flows that start with a trigger as the triggers activate based on an external event. So, before you can test the flow, you must configure the external app to send a message to the trigger to activate it and consequently execute the flow. The play a test case once feature eliminates the need to activate the trigger to execute the flow.

You provide the input to the flow in playing a test case once. It executes the flow on demand without using a trigger. Each activity executes independently and displays its logs. It can help detect errors in the flow upfront without actually building the app. You can use several modes, such as Mock Output and Skip Execution. For more information on modes, see Creating and Running a Test Case.

After creating a test case, it is ready to run in a local runtime environment. You can play a test case once to test against a particular set of flow inputs.

    Procedure
  1. Create a test case. For more information, see Creating and Running a Test Case.
  2. To run a test case, click the icon on the .flogotest file.
  3. View the execution logs of the flow in the terminal. The execution path is highlighted in blue and other activities appear grayed out. You see a new or updated test results file with additional input, output, or error data captured during activity execution.
  4. Click the executed tasks to see the inputs, outputs, or errors of the activity in read-only mode. If an activity is executed and does not have any configuration or output, you cannot click it after execution.

When a test case is running, the Main Flow tab, the Error Handler tab Stop Testcase, Go Back, and Zoom in/out buttons are enabled. All inactive test cases, search and addition of new test cases, Flow input, and Flow output are unavailable.

Tip:
  • You must stop the testing mode to configure the test case.
  • When a test is running, the icon changes to the icon. You must stop an ongoing test case to run a different one.

Handling Errors

If an activity encounters errors, it is highlighted with a red border.

You can perform the following steps:

  1. Click the activity to see a detailed error message.

  2. Go to Error Handler if the main flow activity has an error handler flow.

Using App Executable

Using this feature, you can test a case with the app executable.

  1. To enable this feature, use the app executable.

  2. Use the --test-preserve-io flag in test commands for running a unit test. For more information, see Unit Testing for the CI/CD.
    Or, set the environment variable FLOGO_UT_PRESERVE_IO to true.

If Step 2 is not done, the system defaults to the previous behavior. After the execution is complete, you can see the executed activity logs in the terminal and the test results file is updated.