How to write the result of tests into a file

Hi,

I’m start running integration tests with mix run path/test.exs
The result is something like:

IntegrationTests

  • test 1 (1.2ms)
  • test 2 (11022.7ms)
  • test 2 (5000.9ms)

Finished in 16.0 seconds (0.04s on load, 16.0s on tests)
3 tests, 0 failures

How can I log this output to a file?

I know how to log the output of the logger to a different backend.
Is there anything similar with the console output?

Thank you!

1 Like

You can pipe the output into a file in your shell: mix test > test_output.txt.

3 Likes

That’s what we are doing right now with a perl-script.
The disadvantage is that we are loosing stdout during mix run is running.
Is there no direct possibility to change the output path in elixir?

1 Like

If all you want is to have the same output go to both stdout and a file then the tee command is exactly what you want:

Usage: mix test | tee test_output.txt (add -a flag if you want to append instead of overwrite)

5 Likes

Maybe use logger_file_backend. I guess - test results - are displayed as info.

1 Like

Thank you

1 Like

I used the tee command but all the warnings are not included. Is there a way to include them into the output file?