Created
April 6, 2022 11:34
-
-
Save tiagoefmoraes/7419d0c731f88c17a5cb0d237418eab0 to your computer and use it in GitHub Desktop.
DefStructTest - cover all `defstruct` calls on your elixir app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.DefStructTest do | |
use ExUnit.Case, async: true | |
test "to cover defstruct" do | |
project_structs() | |
|> Enum.each(&assert &1.__struct__(), to_string(&1)) | |
end | |
defp project_structs do | |
{:ok, modules} = :application.get_key(:my_app, :modules) # change to your app's name | |
Enum.filter(modules, &function_exported?(&1, :__struct__, 0)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment