I think if found out (after a bit of debugging) that Polylith only includes bricks in its classloader based on the namespace declaration in files from normal namespaces and not from test namespaces, am I right? At least that is what I think I am observing
Yeah will do that today!
@tengstrand Hope this explains it well enough https://github.com/polyfy/polylith/issues/523
You have explained the problem really well! It should be possible to report these problems properly, even for the default test runner, so thanks for reporting this!
No problem. Thank you for listening 🙂
I am getting an exotic not very helpful error (below). This is resolved the moment I add a normal namespace to the classpath that (indirectly) requires the necessary bricks for the test namespace
clojure.lang.ExceptionInfo: Error while evaluating form (do (clojure.core/use (quote clojure.test)) (clojure.core/require (quote my-project.example-test)) (clojure.test/run-tests (quote my-project.example-test))) in class-loader. Cause: java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.loadClass(String)" because "class_loader" is null {:form (do (clojure.core/use (quote clojure.test)) (clojure.core/require (quote my-project.example-test)) (clojure.test/run-tests (quote my-project.example-test)))}
at polylith.clj.core.test_runner_orchestrator.core$__GT_eval_in_project$fn__11520.invoke(core.clj:110)
at polylith.clj.core.clojure_test_test_runner.core$run_test_statements$fn__35648.invoke(core.clj:59)
...
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.loadClass(String)" because "class_loader" is null
at polylith.clj.core.common.class_loader$invoke_in_STAR_.invokeStatic(class_loader.clj:28)
at polylith.clj.core.common.class_loader$invoke_in_STAR_.doInvoke(class_loader.clj:27)
at clojure.lang.RestFn.invoke(RestFn.java:494)Or maybe I had the wrong assumption/mental model that Polylith was figuring out what bricks belongs together 🙈 It always felt like that hehe, but maybe there was no magic after all
Ok didn't find the exact cause yet, but I'm switching to Sean's test runner which gives me much better feedback
You can include :verbose to the test command to see which namespaces that are included.
I did try verbose and it was telling me the namespace was included, but it was still not obvious what the problem was with that namespace. I've seen different scenarios where I was just guessing what was wrong. Sean's test runner points me to the exact line and cause so that is a big difference.
Could you summarise this in an issue, and include the improved error message that Sean's test runner gave you? That would help if this is something that can be fixed in the default test runner! @jeroenvandijk
A minor update of my https://github.com/seancorfield/polylith-external-test-runner:
• Fix https://github.com/seancorfield/polylith-external-test-runner/issues/11 by supporting :jvm-opts in poly test property handling.
• Address https://github.com/seancorfield/polylith-external-test-runner/issues/8 by noting that the standalone poly tool cannot be used with external test runners.
io.github.seancorfield/polylith-external-test-runner
{:git/tag "v0.6.1" :git/sha "d0f51c2"
:deps/root "projects/runner"}
Thank you Sean!