Skip to content

Commit

Permalink
Merge pull request #1692 from ThusharaSampath/dev
Browse files Browse the repository at this point in the history
Add unit testing doc page
  • Loading branch information
Nashaath authored Feb 25, 2025
2 parents 336bfa3 + 74fb01e commit 1d7a0f0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions en/.spelling
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ WebApps
cron
deployment.toml
subpath
helloworld
codebase
libs
work-with-the-micro-integrator-runtime-in-choreo
Expand Down
2 changes: 2 additions & 0 deletions en/docs/choreo-concepts/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Choreo auto-generates build pipelines that may slightly differ depending on the
- Pushes the container image to a container registry. In the cloud data plane, Choreo pushes the image to a Choreo-managed registry. If it is a private data plane organization, Choreo pushes the image to a registry that you own.
- Updates service endpoints and API specifications from the provided repository if applicable.

In addition to these steps, some buildpacks support integrating unit tests into the build pipeline. For more details, see [Integrate Unit Tests into the Build Pipeline](../develop-components/integrate-unit-tests-into-the-build-pipeline.md).

### Repeatable builds

Choreo can replicate builds from an identical code version (Git commit). This means that multiple builds initiated from the same Git commit will generate Docker images with the same behavior.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Integrate Unit Tests into the Build Pipeline

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.

!!! note
Currently, Choreo supports unit tests only for the `WSO2 MI` buildpack.

## How it works

### Step 1: Write tests

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/).

### Step 2: Enable unit tests

1. Sign in to the [Choreo Console](https://console.choreo.dev/).
2. In the **Component Listing** pane, click the component for which you want to enable unit tests.
3. In the left navigation menu, click **Build**.
4. On the **Build** page, click to edit **Build Configurations**.
5. Turn on the **Unit Test** toggle.
6. Click **Save**.

### Step 3: Trigger a new build

- On the **Build** page, click **Build Latest**.

This starts a new build with unit tests enabled. You can monitor its progress in the **Build Details** pane.

## View failed unit tests

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.

## Explore a sample

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.
3 changes: 2 additions & 1 deletion en/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ nav:
- Develop Components With Git: develop-components/develop-components-with-git.md
- Bring Your Own Image: develop-components/bring-your-own-image.md
- Deploy an Application with Buildpacks: develop-components/deploy-an-application-with-buildpacks.md
- Deploy a Containerized Application: develop-components/deploy-a-containerized-application.md
- Deploy a Containerized Application: develop-components/deploy-a-containerized-application.md
- Integrate Unit Tests into the Build Pipeline: develop-components/integrate-unit-tests-into-the-build-pipeline.md
- Share and Reuse Components:
- Create a Connection: develop-components/sharing-and-reusing/create-a-connection.md
- Use a Connection in Your Service: develop-components/sharing-and-reusing/use-a-connection-in-your-service.md
Expand Down

0 comments on commit 1d7a0f0

Please sign in to comment.