当使用混合测试运行一组测试时,我得到了
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.414.0>.
When using ownership, you must manage connections in one
of the three ways:
* By explicitly checking out a connection
* By explicitly allowing a spawned process
* By running the pool in shared mode
The first two options require every new process to explicitly
check a connection out or be allowed by calling checkout or
allow respectively.
The third option requires a {:shared, pid} mode to be set.
If using shared mode in tests, make sure your tests are not
async.
If you are reading this error, it means you have not done one
of the steps above or that the owner process has crashed.
我已在test / test_helper.exs中将Ecto.Adapters.SQL.Sandbox.mode(Secure.Repo, :manual)
替换为Ecto.Adapters.SQL.Sandbox.mode(Secure.Repo, {:shared, self()})
。
测试失败属于同一测试文件,我没有使用ExUnit.Case, async: true
。
如果我孤立地运行它们,它们运行正常。仍然不能完全确定它是否与使用MySQL服务器并行运行的测试有关。