Testing a phoenix controller

published on
The snippet below is a phoenix framework controller test defmodule PaymentServiceWeb.Controllers.PaymentTest do use ExUnit.Case, async: false use Plug.Test alias PaymentServiceWeb.Router @tag endpoint: true test "service health check" do conn = conn(:get, "/api") response =, @opts) assert %Plug.Conn{resp_body: body} = response end end Explanation The test above is going to test an api endpoint, and the simple assertion is just to ensure that a %Plug.Conn struct is received as the response. Read More...