0

When I run mix test I get all the results back in the shell. How can I get the results to more places like slack, files etc..?

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Yoni S
  • 36
  • 1
  • 7

2 Answers2

1

To write the results of mix test to a file you can do:

mix test > results.txt

To post them on Slack you can use their web API, which you can find here: https://api.slack.com/web

Simone
  • 20,302
  • 14
  • 79
  • 103
  • Your suggestion is local solution, I want some thing that can automatically do it and give me control on the massage. I have in my code connection to slack API but I don't know how can I get the logs so I can send there. – Yoni S Jul 07 '20 at 17:10
  • 1
    You could read the file and send the content using curl. `results=cat results.txt` `curl -X POST -H "Content-Type: text/plain" --data $results http://api.slack.com` – Danstan Jul 08 '20 at 05:16
  • There is no way to configure in the app some how? – Yoni S Jul 08 '20 at 09:42
0

I found answer for my question in https://stackoverflow.com/a/41350442/11678286. To config your own configuration for ExUnit results I need to implement my own formatter (see https://github.com/elixir-lang/elixir/blob/master/lib/ex_unit/lib/ex_unit/cli_formatter.ex for an example; that's the default formatter) and configure ExUnit to use it:

ExUnit.start(formatters: [YourFormatterModule])

For send the result to other places (like slack) I just need to copy the default formatter and add function there that send it to salck too.

Yoni S
  • 36
  • 1
  • 7