# Testing incrementally

The Polylith architecture can support incremental testing if we build tools for it.

The illustrations here are based on the previous [Sharing code](/polylith/introduction/sharing-code.md) page. Now let's see how we can test code incrementally in Polylith.

Here are our bricks. If only the red brick is changed…

<div align="left"><figure><img src="/files/vdGBga1mhgj5vT1jJdmU" alt=""><figcaption></figcaption></figure></div>

…we can calculate which services and bricks that are affected, by checking how the bricks depend on each other:

<div align="left"><figure><img src="/files/vp44MxIR4eIMJ5qVamha" alt=""><figcaption></figcaption></figure></div>

Because the red brick is changed, we know that we need to execute the tests for the red, yellow, and blue bricks, from service A, because they are all directly or indirectly affected by the change. The green and purple bricks are not affected and we can therefore skip testing them.

Tests that are run incrementally run faster as we usually don’t need to run the entire test suite. This applies both when we run tests locally and in the CI build.

An example of a tool that supports incremental testing is the [poly tool](https://cljdoc.org/d/polylith/clj-poly/CURRENT/doc/readme) for [Clojure](https://en.wikipedia.org/wiki/Clojure).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polylith.gitbook.io/polylith/introduction/testing-incrementally.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
