Log does not print when running "mix test"

I am trying to debug while the test is not running, I have my test, and I am trying to print something so that I can see the values โ€‹โ€‹of the tuple when running the mix test . I tried to do this:

 require Logger test "creates element", %{conn: conn} do Logger.debug "debugging #{inspect conn}" conn = post conn, v1_content_path(conn, :create), content: @valid_attrs ... ... end 

But nothing is printed! It drives me crazy! That's where I read to do what I do. How to print a connection connection fairly?

Edit Also tried using:

 IO.puts "debugging #{inspect conn}" 

Edit Here is the contents of my test_helper.exs

 ExUnit.start Mix.Task.run "ecto.create", ~w(-r TestApp.Repo --quiet) Mix.Task.run "ecto.migrate", ~w(-r TestApp.Repo --quiet) Ecto.Adapters.SQL.begin_test_transaction(TestApp.Repo) 

Edit Here is my entire testing file:

 defmodule TestApp.ContentControllerTest do require Logger use TestApp.ConnCase @valid_attrs %{title: "Content Title", url: "http://www.content.com"} @invalid_attrs %{} setup %{conn: conn} do conn |> put_req_header("accept", "application/json") {:ok, conn: conn} end test "my first test", %{conn: conn} do Logger.debug "debugging #{inspect conn}" end end 

Edit Here is the detail of the mix test :

 $ mix test . Finished in 2.5 seconds (0.6s on load, 1.9s on tests) 1 tests, 0 failures Randomized with seed 685273 
+5
source share
1 answer

compile_time_purge_level

As pointed out in some comments on your question, compile_time_purge_level can be reduced to :debug for the test environment by changing the configuration :logger in config/test.exs .

test.exs

 config :logger, backends: [:console], compile_time_purge_level: :debug 

run tests again

 mix test 
+9
source

Source: https://habr.com/ru/post/1246114/


All Articles