DEV Community

Cover image for One step to speed up testing cycle based on code diff. For multiple languages.
williamfzc
williamfzc

Posted on

One step to speed up testing cycle based on code diff. For multiple languages.

squ is a simple enough tool to squeeze your test suites and speed up testing cycle based on code diff.

Before vs After

Before: I have to run all the cases for even a tiny change, which takes 40 minutes. Which means 0.32 USD per push.

image

$ pytest --collect-only
============================= test session starts ==============================
platform darwin -- Python 3.7.4, pytest-7.2.2, pluggy-0.12.0
rootdir: /Users/fengzhangchi/github_workspace/stagesepx
plugins: cov-2.7.1
collected 45 items

...

========================= 45 tests collected in 15.30s =========================
Enter fullscreen mode Exit fullscreen mode

After: Only need to run the influenced cases.

image

$ ./squ | xargs pytest --collect-only
============================= test session starts ==============================
platform darwin -- Python 3.7.4, pytest-7.2.2, pluggy-0.12.0
plugins: cov-2.7.1
collected 5 items

...

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================= 5 tests collected in 14.93s ==========================
Enter fullscreen mode Exit fullscreen mode

All you need is simply adding the ./squ | xargs prefix.

Usage

Language Before After
Python pytest squ | xargs pytest
Java mvn test squ | xargs mvn test
Golang go test squ | xargs go test

But brings much benefits:

Repo Language Analyze time Before Cases After Cases Optimize
stagesepx (our own case) Python ~1 s 45 0~15 ~75%
Jacoco Java ~7 s 1364 0~983 ~50%
sibyl2 Golang ~1 s 53 0~20 ~70%

See https://github.com/opensibyl/squ for details!

Top comments (0)