# Test Lifecycle & Auto-Healing

The entire flow is designed to make running and maintaining tests feel smooth and low effort.

{% stepper %}
{% step %}

### &#x20;Analyse Codebase&#x20;

When you install Kerno, it scans your project, reviews your structure, and builds a detailed graph that shows how components relate to each other. This graph becomes the foundation for planning and executing tests with awareness of your actual system.
{% endstep %}

{% step %}

### Create a Baseline

If your project contains no Kerno tests, the first action is to create initial coverage for your endpoints or routes. During this stage, Kerno sets up a baseline set of behaviours for each endpoint. This gives the project a starting point that Kerno can track over time.

{% hint style="success" %}
This step is only executed where there are no Kerno tests for an endpoint
{% endhint %}
{% endstep %}

{% step %}

### Create Test Plan

Using the code graph and baseline rules, Kerno creates a test plan. It selects an appropriate mix of test categories and assigns suitable priorities with a focus on the most important behaviours.
{% endstep %}

{% step %}

### Generate & Execute Tests

Kerno generates the required test code, prepares the expected scenarios, and runs everything against the test environment it started on your local machine. While doing so, it automatically corrects issues inside the test code until the full set runs without errors.

{% hint style="success" %}
\[IMPORTANT ] Kerno will never makes changes to your code
{% endhint %}
{% endstep %}

{% step %}

### Produce Baseline Report

After the test suite completes, Kerno produces a scenario report. You can open it in your editor to see the exact scenarios Kerno covered and their results.

{% hint style="info" %}
&#x20;This is essentially shows you how your code currently behaves. If you see something off  fix your code and re-run the tests
{% endhint %}
{% endstep %}

{% step %}

### Test Your Code Change

Once an endpoint has an established baseline, any future code changes trigger a comparison step. When you run the tests again, Kerno checks the updated behaviour against the original baseline.
{% endstep %}

{% step %}

### Review Diff Report

If any behaviour differs, Kerno presents a clear list of changes. You can either accept the diffs or adjust your code to and run the tests to get to the baseline behaviour.&#x20;
{% endstep %}

{% step %}

### Auto Heal and Update Test Suite

When you accept a difference, Kerno updates the scenario to reflect the new expected behaviour. It also analyzes the updated code to determine whether new scenarios should be created or existing ones should be removed.&#x20;
{% endstep %}
{% endstepper %}

{% hint style="info" %}
If you encounter issues or have questions, [message us on Slack](https://join.slack.com/t/kerno-community/shared_invite/zt-2tiblmlpx-c05QvbiOEZ_lWUtxECUKWA), and we’ll gladly help.
{% endhint %}
