Skip to main content
New

Smart unit test execution: only run tests for affected objects

Related products:Software Factory
  • Nov 11, 2026 1:05 PM UTC
  • 3 replies
  • 68 views

Forum|alt.badge.img+4

Idea

The Software Factory already supports smart upgrades, which upgrade only what has changed. I'd like the same principle for unit tests: when running an upgrade or a creation, only execute the unit tests of objects that were affected by the changes, and run the full set separately.

Why

We now generate a large share of our unit tests with AI, which makes our test suites many times bigger than when we wrote them by hand. On one application with about 125 tables we have around 1,500 unit tests, and a full run takes 30 to 40 minutes. While it runs, the branch is occupied: we can't generate the definition, so development on that branch stops for the duration.

Most of that time is spent for nothing. In a typical change only a small part of the model is touched, yet every test is executed, including the tests for the large majority of objects that did not change at all.

Proposal

  1. Smart run during upgrade/creation. Only run the unit tests whose object is affected by the changes since the last successful run. Ideally this includes dependencies: a test on a task that calls a changed subroutine should also run.
  2. Full run on schedule. The ability to schedule a run of all unit tests, for example nightly, so the full regression still happens without blocking development during the day.
  3. Full run on demand. Keep the option to start a full run manually, for example before a delivery or release.

Result

Short feedback loops during development, no idle time on the branch, and the full safety net still in place where it matters: nightly and before delivery.

3 replies

Forum|alt.badge.img
  • Rookie
  • Nov 27, 2026 8:49 AM UTC

I fully support this idea. Smart unit tests would eliminate the long wait when only a few control procedures were added. 

 

In the same vein as this topic, I would also like to suggest the following. 

  1. On demand smart unit tests.
  2. Unit test status updates to the question mark ‘not executed’ when updated in the same way that code objects do. This should happen when:
    1. The unit test has been updated (input parameters, expected output / message, mock data, preparation or assert query)
    2. The linked object has been changed.

The smart unit test can then either run all ‘not executed’ unit tests or all tests for objects changed in this branch. 


Kevin Horst
Thinkwise blogger
Forum|alt.badge.img+5
  • Thinkwise blogger
  • Dec 1, 2026 12:25 PM UTC

Fully agree, and I can add a data point from the other end of the scale.

In a migration project we now have almost 13,000 unit tests for 3,495 control procedures, most of them generated. A run of about 7,000 tests already took around 25 minutes on a quiet server and several hours when the server was busy. Generating the unit test code during deployment took 86 minutes in one branch. So at this size it is not only the execution: the generation step should be smart too, otherwise we still wait well over an hour before the first test even starts.

A few additions to the proposal, from what we ran into:

  • Dependencies beyond subroutines. Besides "a task that calls a changed subroutine", two cases matter a lot for us: a changed template should select the tests of every procedure it is assigned to, and a change to a table, column or domain should select the tests whose data set or mock data uses it.
  • Run a selection. Today the task that starts a run (task_add_job_to_test_unit_test) always runs everything. Even before full smart detection exists, being able to run a hand-picked set of tests or objects (or "failed last time") would already save a lot of time when fixing a few tests.
  • Keep the other results. After a smart run, tests that were not executed should keep their last result, marked as unchanged. Combined with Leo's suggestion (reset to "not executed" when the test or its object changes), the overview then always shows which results are current.
  • Same options everywhere. Smart, full, failed-only and selection as a choice in the deployment preset, the scheduler (full run at night, as suggested above) and when starting a run through Indicium or the API, so a pipeline can do the same.

This would make large, AI-generated test sets practical in daily development instead of something you only run at night.


Kevin Horst
Thinkwise blogger
Forum|alt.badge.img+5
  • Thinkwise blogger
  • Dec 2, 2026 12:34 PM UTC

Follow-up to my comment above: while waiting for this to become a product feature, I built an experimental Claude Code skill that works around it.

After a deployment, it selects only the unit tests that can be affected by the change and runs those instead of the full set:

  • It makes a fingerprint per test: the generated test code plus every database object that code uses, followed transitively.
  • A test is selected when it is new, failed last time, or its fingerprint differs from the last passing run.
  • It starts the selection as one job through the multi-select task (task_add_job_to_test_unit_test_single), because the normal task always runs everything.

On one branch, 8 selected tests ran in about 2 minutes, against 64 minutes for a full run of roughly 12,800 tests.

It is not an official Thinkwise feature and it can miss tests, for example when dependencies go through dynamic SQL. Use it at your own risk and keep a full run for a new baseline. It is verified on one project only.

I attached the skill file. It describes the approach step by step; the helper scripts are not included but claude code can recreated those based on the skill.