This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # babashka (7)
- # beginners (25)
- # calva (22)
- # cljs-dev (1)
- # clojure (62)
- # clojure-europe (118)
- # clojure-hamburg (4)
- # clojure-israel (2)
- # clojure-nl (2)
- # clojure-uk (6)
- # clojured (1)
- # clojurescript (23)
- # conjure (11)
- # cursive (3)
- # datomic (14)
- # duct (2)
- # emacs (12)
- # figwheel-main (1)
- # gratitude (1)
- # hyperfiddle (4)
- # joyride (72)
- # lsp (46)
- # luminus (1)
- # malli (1)
- # off-topic (54)
- # pathom (19)
- # polylith (11)
- # releases (2)
- # sci (22)
- # shadow-cljs (4)
- # vim (11)
- # xtdb (52)
how can I run tests of a component that is not (yet) used in any base?
test brick:xyz doesn’t do anything unless the component is used in a base. Or am I missing something?
another: running tests of a component used in multiple bases, makes the component tests are run once for each base. Used in 6 bases -> the tests are run 6 times. Is this intentional?
Tests run in the scope of each project. In order to run tests in isolation, Polylith tool creates a new classloader with correct bricks and dependencies for each project. Since the tests might fail (e.g. they are not unit and depend on other component functionality) based on the project that the component is included, they run for each project that the component is included. 👉 Detailed documentation about testing is https://polylith.gitbook.io/poly/workflow/testing.
tl;dr; • component should be included in a project in order to run test, or at least in the development project • tests run for each project that component is included
You can override the default behavior and tell that, lets say, only one project should run the tests and the rest shouldn’t. You can specify a vector of components for each project that the tests should run. If you provide an empty vector, no tests run for that project. You can check Polylith’s own https://github.com/polyfy/polylith/blob/master/workspace.edn as an example which instructs
api project should not run any tests but
Development project does not run tests by default.
@U055NJ5CC If you do
test :dev brick:xyz it should run (because all bricks should be listed in the
@U04V70XH6 that did the trick, thanks!
Am I correct that, using another words, this testing duplication design addresses the case of A depending on B in one project and A depending on B’ (same interface) in another one?
That is certainly one aspect of it (we have two swappable components that each have different implementations in two different projects). Projects may also have different 3rd party library versions (that has been true for us for quite a while, up until recently, so we needed to test several bricks against the appropriate versions of 3rd party libraries).
Found another use case for swappable components last week: we have a "preview" app that provides a small web server that renders HTML templates using Selmer that our UI/UX designer uses when writing templates for email campaigns. They recently asked for new functionality that I implemented as new custom tags in Selmer but that meant adding more bricks to the
preview project, which ended up pulling in a lot more libraries and bloating the size of the
preview JAR. So I created a swappable implementation of our main
i18n component that essentially stubbed out everything the
preview app didn't need (it pulls data from a JSON file instead of a database), which eliminated all those extra libraries, removing about 3MB from the JAR. I'll probably refactor the "preview" version of
i18n so I don't have to override the
resource tag in the
preview-web base which will clean up some code.