I have a medium-sized release with a handful of applications. I recently refactored some common functionality out into a library application within the release. This made my EUnit tests fail with undef
messages whenever testing anything that required the library application.
The set up is something like this:
% In apps/utils/src/utils.erl
-module(utils).
-export([foo/0]).
foo() -> "OH HAI".
Then
% In apps/some_app/src/some_app.erl
-module(some_app).
-export([bar/0]).
bar() -> io:format("foo: ~s~n", [utils:foo()]).
% unit tests for bar()
Then the unit tests for some_app:bar()
fail. I'm running them with rebar eunit skip_deps=true
. I'm using skip_deps=true
because my release uses some 3rd party applications (SQL, etc).
I assume that the tests start failing because EUnit is invoking the app under test without its dependencies? Is there any way to fix this? I have configured the .app file to explicitly declare the dependency. It works fine in the release, and it's been deployed for about a day now with no problem, but I'll feel a lot better if I can get the tests to pass again :)
(I could use a mocking app to stub out utils:foo/0
, and I can see where that would be ideal idiomatically, but that seems like overkill in this case because utils:foo/0
(read: it's real-world counterpart) does some really simple stuff.)
skip_deps
flag just skips the unit tests in thedeps
directory (which is being used for 3rd-party stuff). – Governessskip_deps
just tells rebar to skip applications in thedeps
directory. – Governess