Errol Hassall
Errol Hassall

Reputation: 416

Generating elixir test folder & scaffolding

Is it possible to generate the entire test folder and structure from mix or can it only be done when you first create the project? I need to recreate the entire test folder on an already existing project

Upvotes: 1

Views: 287

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121020

mix generates a very limited scaffold for the test folder:

* creating test
* creating test/test_helper.exs
* creating test/my_project_test.exs

that said, there are two files in a folder:

test/test_helper.exs

ExUnit.start()

test/my_project_test.exs

defmodule MyProjectTest do
  use ExUnit.Case
  doctest MyProject

  test "greets the world" do
    assert MyProject.hello() == :world
  end
end

That’s it. AFAIK, mix is unable to generate tests according to your code. It cannot [at the moment of writing this] scaffold a test based on some source file. I am also unaware of any 3rd party package that could help here.

Upvotes: 2

Related Questions