Say I have component A that makes use of component B, and I have B-production and B-mock (for testing). Does it make sense for A to have a :dev dependency on B-mock for use in unit tests, or does all cross-component testing need to be inside a project? And, if so, are some projects just about testing and not artifacts?
This is what profiles are for.
Components never depend on each (in deps.edn files). Only projects (including development) specify those dependencies.
Example from our work monorepo:
:+default {:extra-deps {;; by default, we use the real i18n and web server:
poly/i18n {:local/root "components/i18n"}}
:extra-paths ["components/i18n/test"]}
:+preview {:extra-deps {;; or the preview i18n and the real web server:
poly/i18n {:local/root "components/i18n-preview"}}
:extra-paths ["components/i18n-preview/test"]}
(the comment is because we used to have a mock web server component—and we also used to have two HTTP client components: one for JDK 8 and one for JDK 9+)Alternately, do you do mocking via with-redefs on the functions called in the interface?
Yes, we sometimes mock with-redefs (for all its many faults).