Background
I have a specific test where I need to spawn a cowboy server listening on port 8082 that returns some static responses.
Objective
Normally I would spin up a cowboy process in my application.ex
file like this:
def start(_type, args) do
children = children([{Cowboy, scheme: :http, plug: MyServer, options: [port: 8082]}])
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
But the code I am working on is not an application, so I can't do that.
My objective is to use the setup_all
callback of ExUnit to do this, however I don't know how to do it or if it is possible.
Questions
- How can I start a cowboy server in ExUnit?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…