OptimumCredo.Check.Readability.TestPathMismatch (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of low and works with any version of Elixir.

Explanation

A test file mirrors its subject: lib/my_app/x.ex is tested by test/my_app/x_test.exs, and the test module is named <Module>Test.

Bad

# test/my_app/invoice_test.exs
defmodule MyApp.BillingTest do
end

Good

# test/my_app/invoice_test.exs
defmodule MyApp.InvoiceTest do
end

Feature, integration, and support tests are exempt by directory. The counterpart lookup reads the working tree.

Check-Specific Parameters

Use the following parameters to configure this check:

:ignore_paths

Path fragments to skip.

This parameter defaults to [].

:require_test_counterpart

Require an existing lib/ file at the mirrored path.

This parameter defaults to true.

:web_layer_dirs

Layer directories that may be omitted below a *_web root.

This parameter defaults to ["controllers", "live", "components", "channels", "plugs"].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.