Fork me on GitHub
#polylith
<
2024-05-27
>
joshkh19:05:20

hello! i have a polylith monorepo with a component that handles database CRUD. it has many unit tests that setup and teardown databases using opentables. since the component is used in many bases, running test from the poly CLI redundantly runs the component’s unit tests for every base, taking up a lot of time. have i fallen into an antipattern?

seancorfield20:05:56

What we do at work is run a setup/teardown function for each project, and part of that is setting up DB stuff, rather than having each unit test doing it (so our unit tests can assume the DB exists with the right schema and seed data, and can add/remove just the data each test needs).

seancorfield20:05:48

Also, if that component doesn't change, it won't get tested (by default). So you might want to think about frequency of change, and whether your component would be better split into different components where most of those are stable and only a few are changing?

seancorfield20:05:16

Having very narrowly focused components really helps in terms of not testing the whole world each time...

Teemu Kaukoranta06:05:34

sorry for the tangent, but what is opentables?

joshkh19:05:41

@U04V70XH6. thanks for that. and yup, i think the underlying problem is that i have all of my CRUD in a single i/o component, rather than organised in a more granular way (for example CRUD by business entity). since my i/o component is used by all projects it triggers a lot of tests when changed. still, they’re unit tests. it would be cool to exclude a re-run of component level unit tests if they were already run by another project (but maybe that’s naive). @U0NCTKEV8 thanks for sharing the link to @UCQGNA673!

seancorfield20:05:56

I don't think that repo is maintained? I use the Zonsky fork which is actively maintained. See the next.jdbc test deps.

tengstrand20:05:03

If you are sure you only need to run your tests in e.g. one project, then you can skip running brick tests for the other projects, see https://cljdoc.org/d/polylith/clj-poly/0.2.19/doc/testing#include-exclude @U0H46T23C

joshkh20:05:29

@U1G0HH87L thank you, i’ll take a look

👍 1