Skip to content

Instantly share code, notes, and snippets.

@tiagoefmoraes
Created April 6, 2022 11:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagoefmoraes/7419d0c731f88c17a5cb0d237418eab0 to your computer and use it in GitHub Desktop.
Save tiagoefmoraes/7419d0c731f88c17a5cb0d237418eab0 to your computer and use it in GitHub Desktop.
DefStructTest - cover all `defstruct` calls on your elixir app
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