Repository metrics
- Stars
- (7,981 stars)
- PR merge metrics
- (Avg merge 5d 19h) (41 merged PRs in 30d)
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
Noticed lots of test failures when running tests locally. The found I have to start tests with clean database. Oops.
But even then, was getting errors - up to 7. Then I found if I ran test files individually, was more like to work.
At a hunch I made the following change:
diff --git a/test/teslamate/vehicles/vehicle/charging_test.exs b/test/teslamate/vehicles/vehicle/charging_test.exs
index 106d64df..26fb4f65 100644
--- a/test/teslamate/vehicles/vehicle/charging_test.exs
+++ b/test/teslamate/vehicles/vehicle/charging_test.exs
@@ -1,5 +1,5 @@
defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do
- use TeslaMate.VehicleCase, async: true
+ use TeslaMate.VehicleCase, async: false
alias TeslaMate.Vehicles.Vehicle.Summary
alias TeslaMate.Log.ChargingProcess
diff --git a/test/teslamate/vehicles/vehicle/streaming_test.exs b/test/teslamate/vehicles/vehicle/streaming_test.exs
index 20f54723..c43db381 100644
--- a/test/teslamate/vehicles/vehicle/streaming_test.exs
+++ b/test/teslamate/vehicles/vehicle/streaming_test.exs
@@ -1,5 +1,5 @@
defmodule TeslaMate.Vehicles.Vehicle.StreamingTest do
- use TeslaMate.VehicleCase, async: true
+ use TeslaMate.VehicleCase, async: false
import ExUnit.CaptureLog
diff --git a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
index ae3d6677..f282debe 100644
--- a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
+++ b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
@@ -1,5 +1,5 @@
defmodule TeslaMate.Vehicles.Vehicle.SuspendLoggingTest do
- use TeslaMate.VehicleCase, async: true
+ use TeslaMate.VehicleCase, async: false
alias TeslaMate.Vehicles.Vehicle.Summary
alias TeslaMate.Vehicles.Vehicle
diff --git a/test/teslamate/vehicles/vehicle/suspend_test.exs b/test/teslamate/vehicles/vehicle/suspend_test.exs
index b89ee958..d8561f03 100644
--- a/test/teslamate/vehicles/vehicle/suspend_test.exs
+++ b/test/teslamate/vehicles/vehicle/suspend_test.exs
@@ -1,5 +1,5 @@
defmodule TeslaMate.Vehicles.Vehicle.SuspendTest do
- use TeslaMate.VehicleCase, async: true
+ use TeslaMate.VehicleCase, async: false
alias TeslaMate.Vehicles.Vehicle.Summary
Now all the tests pass for me. I suspect we have race conditions with multiple tests interfering with the database at the same time. Yuck.
Not sure I like this, but I think as our tests access the database they are more like integration tests not unit tests, and as a result they really do need to be run sequentially.
Expected Behavior
Tests pass without failures.
Steps To Reproduce
MIX_ENV=test mix test
Relevant log output
(after fix applied)
$ MIX_ENV=test mix test
....................................................................................................................................................................................................................................................................................................................................
Finished in 23.3 seconds (4.4s async, 18.8s sync)
324 tests, 0 failures
Randomized with seed 392195
Screenshots
No response
Additional data
No response
Type of installation
Docker
Version
master