|
2 | 2 |
|
3 | 3 | Choreo allows you to integrate unit tests into the build pipeline, enabling code validation before deployment. This ensures early testing of code changes, reducing the risk of defects in production. |
4 | 4 |
|
5 | | -!!! note |
6 | | - Currently, Choreo supports unit tests only for the `WSO2 MI` build preset. |
| 5 | +Currently, Choreo supports unit tests only for the `WSO2 MI` and `Ballerina` build presets. |
7 | 6 |
|
8 | | -## How it works |
| 7 | +## Write tests |
9 | 8 |
|
10 | | -### Step 1: Write tests |
| 9 | +You can create unit tests in your source code using standard testing libraries. For step-by-step instructions on creating unit tests for WSO2 Micro Integrator projects, see [Creating a Unit Test Suite](https://mi.docs.wso2.com/en/latest/develop/creating-unit-test-suite/). For step-by-step instructions on writing unit tests for Ballerina projects, see [Test Ballerina Code](https://ballerina.io/learn/test-ballerina-code/structure-tests/). |
11 | 10 |
|
12 | | -You can create unit tests in your source code using standard testing libraries. For step-by-step instructions on creating unit tests for WSO2 Micro Integrator projects, see [Creating a Unit Test Suite](https://mi.docs.wso2.com/en/latest/develop/creating-unit-test-suite/). |
| 11 | +Once you have written your unit tests, commit them to your source code repository. |
13 | 12 |
|
14 | | -### Step 2: Enable unit tests |
| 13 | +## Enable unit tests |
| 14 | + |
| 15 | +To enable unit tests in the build pipeline for a component with unit tests in its source code, follow these steps: |
15 | 16 |
|
16 | 17 | 1. Sign in to the [Choreo Console](https://console.choreo.dev/). |
17 | | -2. In the **Component Listing** pane, click the component for which you want to enable unit tests. |
| 18 | +2. In the **Component Listing** pane, click the component for which you want to enable unit tests. |
18 | 19 | 3. In the left navigation menu, click **Build**. |
19 | 20 | 4. On the **Build** page, click to edit **Build Configurations**. |
20 | 21 | 5. Turn on the **Unit Test** toggle. |
21 | 22 | 6. Click **Save**. |
22 | 23 |
|
23 | | -### Step 3: Trigger a new build |
24 | | - |
25 | | -- On the **Build** page, click **Build Latest**. |
| 24 | +## Trigger a new build |
26 | 25 |
|
27 | | -This starts a new build with unit tests enabled. You can monitor its progress in the **Build Details** pane. |
| 26 | +Once you have enabled unit tests, trigger a new build to run them by clicking **Build Latest**. This starts a new build with unit tests enabled. You can monitor its progress in the **Build Details** pane. |
28 | 27 |
|
29 | 28 | ## View failed unit tests |
30 | 29 |
|
31 | | -If a unit test fails during the build, you can view its detailed logs for troubleshooting. Click **View Details** corresponding to the failed build, then expand the failed unit test step to view the logs. |
| 30 | +If a unit test fails during the build, Choreo will stop the build to prevent faulty code from being deployed. To troubleshoot, click **View Details** for the failed build and expand the failed unit test step to review the test output logs. |
32 | 31 |
|
33 | 32 | ## Explore a sample |
34 | 33 |
|
35 | | -To see unit tests in action within the build pipeline, try out the [WSO2 MI helloworld](https://github.com/wso2/choreo-samples/tree/main/hello-world-mi) sample. |
| 34 | +To see unit tests in action within the build pipeline, try out the [WSO2 MI helloworld](https://github.com/wso2/choreo-samples/tree/main/hello-world-mi) sample or the [Ballerina helloworld](https://github.com/wso2/choreo-samples/tree/main/greeting-service) sample. |
| 35 | + |
| 36 | + |
0 commit comments