4

使用 mix test 运行一组测试时,我得到

 ** (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 服务器以并行方式运行的测试有关。

4

0 回答 0