# 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](sharing-code) 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="https://3095132514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAhrWK1psIWk5h5zNLV%2Fuploads%2F6d1mRFReTtbjNgRaibWU%2Fservice.png?alt=media&#x26;token=1ad66d18-d0e4-45e8-9a6c-db6ddde70079" 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="https://3095132514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAhrWK1psIWk5h5zNLV%2Fuploads%2FGbqGxrNP4Knggf8n0Xe5%2Fservice.png?alt=media&#x26;token=c89abdd6-bbd1-4ff2-9e48-a26aafb24044" 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).

