This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-11
Channels
- # announcements (1)
- # aws (5)
- # beginners (35)
- # calva (18)
- # clerk (5)
- # clojure (20)
- # clojure-berlin (1)
- # clojure-dev (12)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (159)
- # clojure-uk (5)
- # clojurescript (8)
- # conjure (1)
- # cursive (18)
- # events (10)
- # fulcro (23)
- # hyperfiddle (5)
- # introduce-yourself (3)
- # juxt (2)
- # off-topic (1)
- # polylith (4)
- # portal (11)
- # releases (1)
- # shadow-cljs (4)
- # xtdb (9)
- # yamlscript (1)
I have a question regarding poly test
. Below is the recap of my situation.
All tests are run using in memory h2 db
(with mysql dialect). The configuration for h2 database including its init script is written in testing
component, to which all other bricks refer in their own :test
alias.
Inside of every deftest
that uses db, there is a function call to init
function from testing
component's interface. They work just fine when jacking-in to repl and running tests directly via run-tests
.
When run via poly test project:project_name
, it succeeds at the very first time. The trials after complains about not being able to find the suitable driver
and throws errors. I'm yet to understand how poly test works under the hood. can anyone shed some light on this problem?
The first thing I can see from your explanation is that you mentioned bricks depend on another brick, testing
, in their deps.edn
. The most crucial rule in Polylith is that bricks do not depend on each other through deps.edn
. They depend on interfaces, and which implementation will be included in the classpath will be decided at the project level. If you have a project named project_name
, and if you want to use testing
brick while testing that project, you can include the testing
brick in the :test
alias of the project_name
project’s deps.edn
.
An example of this can be found in the Polylith repository. https://github.com/polyfy/polylith/blob/408ef27ecad00d3443120f2340fd0d95fa642535/projects/poly/deps.edn#L43, the poly
project uses the test-helper
brick while testing, and https://github.com/polyfy/polylith/blob/408ef27ecad00d3443120f2340fd0d95fa642535/components/creator/test/polylith/clj/core/creator/project_test.clj#L3 is an example of how the creator
brick uses the test-helper
.
These two pages explain how testing works with Polylith:
• https://cljdoc.org/d/polylith/clj-poly/0.2.19/doc/testing
• https://cljdoc.org/d/polylith/clj-poly/0.2.19/doc/test-runners
Without seeing the entire setup and configuration, it’s hard to tell where the problem is. Since poly doesn’t do any magic, it always comes down to what you have in the classpath.
"not being able to find the suitable driver and throws errors" -- this sounds a bit like the classloader isolation problem with tests that some people have gotten around by switching to the external test runner (which uses process isolation instead).