I'd like to change the test_pattern
for mix test
but I'm having trouble figuring out the right way to perform this configuration. I tried a number of variants of configuration in config/test.exs
but never figured it out. Eventually I found that changing mix.exs
(which I think is the highest level config file) worked:
defmodule Server.Mixfile do use Mix.Project def project do [ app: :server, version: "0.0.1", elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps(), test_pattern: "*_test.ex", # ----- this is what worked! ] end # more config stuff end
What's the right way to perform configuration for mix test
?
I came across this hack by looking at this LOC and trying to get my project config to conform to that check. I suspect there's a better way to achieve what I want.
Here's what my config/test.exs
file looks like right now (with some comments)
use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :server, ServerWeb.Endpoint, http: [ port: 4001 ], server: false # Print only warnings and errors during test config :logger, level: :warn config :server, Server.Repo, adapter: Ecto.Adapters.Postgres, username: System.get_env("POSTGRES_USER") || "postgres", password: System.get_env("POSTGRES_PASSWORD") || "postgres", database: System.get_env("POSTGRES_DB") || "postgres", hostname: System.get_env("POSTGRES_HOST") || "localhost", pool: Ecto.Adapters.SQL.Sandbox # test_pattern: "*_test.ex" ---- this doesn't get picked up #config :project, ------------- this complains about the application "project" not being available # test_pattern: "*_test.exs?"