Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 测试嵌套文件夹中的Phoenix控制器_Testing_Elixir_Phoenix Framework - Fatal编程技术网

Testing 测试嵌套文件夹中的Phoenix控制器

Testing 测试嵌套文件夹中的Phoenix控制器,testing,elixir,phoenix-framework,Testing,Elixir,Phoenix Framework,我有一个长生不老药伞应用程序,其中包含一个凤凰应用程序和长生不老药应用程序。应用程序按预期工作,但我在测试其中一个控制器时遇到问题 当我运行测试时,文件中的测试将不会运行。看起来它们在测试过程中不知何故被跳过了 控制器文件看起来像 defmodule AppName.File.Path.NameOfController do def index(conn, params) do render(conn, "index.html") end end defmodule AppNa

我有一个长生不老药伞应用程序,其中包含一个凤凰应用程序和长生不老药应用程序。应用程序按预期工作,但我在测试其中一个控制器时遇到问题

当我运行测试时,文件中的测试将不会运行。看起来它们在测试过程中不知何故被跳过了

控制器文件看起来像

defmodule AppName.File.Path.NameOfController do
  def index(conn, params) do
    render(conn, "index.html")
  end
end
defmodule AppName.File.Path.NameOfControllerTest do
  test "GET /"the_url/I/want", %{conn: conn} do
    conn = get conn, some_path(conn, :index)
    assert html_response(conn, 200) =~ "Some html"
  end
end
测试文件也相当简单,看起来像

defmodule AppName.File.Path.NameOfController do
  def index(conn, params) do
    render(conn, "index.html")
  end
end
defmodule AppName.File.Path.NameOfControllerTest do
  test "GET /"the_url/I/want", %{conn: conn} do
    conn = get conn, some_path(conn, :index)
    assert html_response(conn, 200) =~ "Some html"
  end
end
我的项目中的所有测试都在这个文件上运行,但有一个例外。我认为这可能与文件路径有关,但我看不出这会影响测试的任何原因。我还可以在运行应用程序时转到端点


任何帮助都将不胜感激。提前感谢。

conn=get-conn,一些路径(conn,:index)
应该是
conn=get-conn,路径名称(conn,:index)

为了获得正确的路径帮助器,Phoenix删除尾部的
控制器
,并将名称转换为snake-case并附加
\u-path


因此,
NameOf
变成了
name\u of

是您的测试来自的文件,扩展名为“.exs”(与“.ex”相反)。这让我过去很痛苦。嘿@Scotthompson,是的,文件的扩展名是
.exs
。谢谢你的评论,这肯定是工作检查的一部分。