keliumJU

keliumJU

A single test passes, but if I run the whole test suite, the same test fails

Hello everyone, lately I have encountered this problem, I have seen it happen in several languages, any idea how to deal with it in elixir?

For example, when I run

mix test test/app_web/live/module/index_live_test.exs → pass

but if I do

mix test → only the above test fails

I want to clarify that in my case I use Task.async in that module and in the test I also use Task.async and send() to send those tasks.

P.S: Actually, this works but separating the problematic tests to another test module, I don’t know if this is considered bad practice.

P.S2: Sometimes it was solved with Process.sleep(300) or adding async: true to the ConnCase config.

Thank you very much in advance.

Marked As Solved

keliumJU

keliumJU

Yes I would think they are side effects, because the error it generates can be described as: “it is not reached to send the Task.async therefore no such tasks exist and the test fails”, I have separated the tests that handle Task.async to another describe with a different setup and that works for now for me, thank you very much for the general context of the problem.

P.S: I have not moved any of the test configuration (rollback question).

Also Liked

sodapopcan

sodapopcan

It’s impossible to know without seeing your code but this generally happens because one test is causing persisting side effects that another test is reading. In the past this was usually the database but Phoenix, and most other frameworks, rollback the db state on each test. Did you turn that off, per chance? Another possibility is that one test is writing a file that another is expecting not to be there. There are a lot of different possibilities but that’s the gist of it.

iarekk

iarekk

General overview: your code has mysterious side-effects that make the tests flaky.

Potential steps to investigate:

  1. Isolate the tests into a reproducible and publishable piece of code.
  2. Hire a consultant, have them sign and NDA and debug it in your codebase.

I don’t think a productive discussion can be had with the details you’ve been able to provide so far.

keliumJU

keliumJU

Yes, sorry, ideally I would like to have a project with the reproducible bug, right now I solved it by using a different describe with a different setup for the problematic tests (in same file), in a future post I will be sure to follow the steps you recommend, thank you very much.

Where Next?

Popular in Questions Top

chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement