Running erlang test from mix

Hi,

I’m trying to build an existing Erlang project using mix.
I have lot’s of test already in place that uses common_test.

Is it possible to launch the tests with mix?

Yes. Or Kind of… I know that @hauleth announced some progress doing this in the slack, not sure though if he released something yet.

Unsure if anything prebuilt but it’s pretty easy just to call erlang’s common_test infrastructure from a new mix task, which can be as simple as a function in the mix.exs file.

Yes, in my current company we are using Mix with Erlang projects via

Currently still not released on Hex. Works without many major problems. Only thing I still need to fight with is Lager and SASL log messages which I still try to disable (with no success so far).

3 Likes

@SoapCookie @hauleth I’m curious why mix over rebar3? Personal preference? The fact that other projects at the company are Elixir and use mix so sticking to a single build tool helps? Do the Erlang projects have Elixir dependencies and the rebar3 plugin doesn’t work well enough? Missing features?

Just looking to see if there is anything we can improve.

I want to slowly convert my codebase to elixir (one file at a time) and mix allows me to use both languages in the same app.

Gotcha :+1:

There are actually 2 other projects to do this as well


However none of them gives the same output as rebar3 ct (I think the formatter is in rebar3)
and none of them seem to work with umbrella projects.

Ctex from Comcast is something different. It is to use Common Test in Elixir testing, I have similar library Commoner that I need to expand a little.

About mix-erlang-tasks, I have been using it as a template as there was a lot possible improvements and it was easier for me to start it over instead of forking.

EDIT

My solution produces similar output to rebar3 ct (as this uses the @ferd library with hooks) and it works with Mix umbrellas.

Awesome!

I looked at alternative because I had an issue with your solution.
When I run MIX_ENV=test mix ct I get an error. I guess I’m missing some configuration.

Common Test starting (cwd is /path_to_umbrella/apps/app)

** (Mix) Failed to run common test with reason: :no_suite_specified

I expected mix ct to run every suite in my umbrella project by default.

Nevermind one of my apps had no test/*_SUITE.erl file. Adding one allowed the task to proceed further.