No timeout in tests
Asked Answered
A

2

19

I like to use breakpoints inside my tests to see what's going wrong, but the 30 second timeout on the tests prevents me to look around freely.

Is there a way to disable it ? The following doesn't work :

@tag timeout: 0
test "something" do 
  assert something == 42
end
Aerator answered 9/7, 2015 at 14:55 Comment(0)
P
23

UPDATE:

With Elixir 1.1, you will also be able to run tests with the --trace option: mix test --trace. It will automatically set timeout to infinity.

– José Valim

PRE Elixir 1.1:

Maybe try using:

ExUnit.configure(timeout: 600_000)
# or even:
ExUnit.configure(timeout: :infinity)

Docu and source code

Protectionism answered 9/7, 2015 at 15:4 Comment(2)
With Elixir 1.1, you will also be able to run tests with the --trace option: mix test --trace. It will automatically set timeout to infinity.Penmanship
@JoséValim maybe add this as an answer? Does it also make tests run serially?Comradery
M
9

Creating a new answer since two separate editors on Stackoverflow think that me editing the accepted answer with the actual docs embedded in the code "was intended to address the author of the post and makes no sense as an edit" despite the updated answer being wholly written by the docs authors in the Elixir git repository (lol) and it "was not more accurate" despite giving 4(!) additional ways to set the timeout that isn't outlined in the answer or the comments.

The five ways:

  1. per test by setting "@tag timeout: x" (accepts :infinity)
  2. per test module by setting "@moduletag timeout: x" (accepts :infinity)
  3. globally via "ExUnit.start(timeout: x)" configuration
  4. by running "mix test --timeout x" which sets timeout
  5. or by running "mix test --trace" which sets timeout to infinity

(useful when using IEx.pry/0)

https://github.com/elixir-lang/elixir/blob/v1.10/lib/ex_unit/lib/ex_unit.ex#L144

Marleen answered 25/5, 2020 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.