plug_test_helpers alternatives and similar packages
Based on the "Testing" category.
Alternatively, view plug_test_helpers alternatives based on common mentions on social networks and blogs.
-
hound
Elixir library for writing integration tests and browser automation -
proper
PropEr: a QuickCheck-inspired property-based testing tool for Erlang -
bypass
Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests. -
StreamData
Data generation and property-based testing for Elixir. ๐ฎ -
ExVCR
HTTP request/response recording library for elixir, inspired by VCR. -
propcheck
Property based Testing for Elixir (based upon PropEr) -
excheck
Property-based testing library for Elixir (QuickCheck style). -
amrita
A polite, well mannered and thoroughly upstanding testing framework for Elixir -
ponos
ponos is a simple yet powerful load generator written in erlang -
power_assert
Power Assert in Elixir. Shows evaluation results each expression. -
shouldi
Elixir testing libraries with nested contexts, superior readability, and ease of use -
FakerElixir
[unmaintained] FakerElixir generates fake data for you. -
katt
KATT (Klarna API Testing Tool) is an HTTP-based API testing tool for Erlang. -
Stubr
Stubr is a set of functions helping people to create stubs and spies in Elixir. -
FakeServer
FakeServer integrates with ExUnit to make external APIs testing simpler -
Mockery
Simple mocking library for asynchronous testing in Elixir. -
mecks_unit
A simple Elixir package to elegantly mock module functions within (asynchronous) ExUnit tests using Erlang's :meck library -
mix_test_interactive
Interactive watch mode for Elixir's mix test. https://hexdocs.pm/mix_test_interactive/ -
Walkman
Isolate tests from the real world, inspired by Ruby's VCR. -
test_selector
Elixir library to help selecting the right elements in your tests. -
factory_girl_elixir
Minimal implementation of Ruby's factory_girl in Elixir. -
toxiproxy_ex
ToxiproxyEx is an Elixir API client for the resilience testing tool Toxiproxy. -
ex_parameterized
This library support parameterized test with test_with_params macro. -
mix_erlang_tasks
Common tasks for Erlang projects that use Mix -
cobertura_cover
Output test coverage information in Cobertura-compatible format -
ex_unit_fixtures
A library for defining modular dependencies (fixtures) for ExUnit tests. -
hypermock
HTTP request stubbing and expectation Elixir library -
ElixirMock
Creates clean, concurrent, inspectable mocks from elixir modules
Elixir and Phoenix Application Security Platform
Do you think we are missing an alternative of plug_test_helpers or a related project?
README
Plug Test Helpers
Simple helpers to test your Plugs with ExUnit. Still an experiment in progress at this point.
The library provides a set of macros which can perform assertions on Plug.Conn
structs to verify the response status, headers and body.
Installation
Add the dependency in your mix.exs
file:
def deps do
[ { :plug_test_helpers, "~> 0.1" } ]
end
After you are done, run mix deps.get
in your shell to get install it.
Usage
Add use PlugTestHelpers
to your test case to bring in new Plug-specific assert macros :
defmodule do
use ExUnit.Case, async: true
use Plug.Test
use PlugTestHelpers
@opts MyPlug.init([])
test "status" do
conn = conn(:get, "/")
conn = MyPlug.call(conn, @opts)
assert_status 200
end
test "404" do
conn = conn(:get, "/not-found")
conn = MyPlug.call(conn, @opts)
# Works with symbols toos
assert_status :not_found
end
test "redirect" do
conn = conn(:get, "/redirect")
conn = MyPlug.call(conn, @opts)
# Will check both HTTP status code and header
assert_redirect "http://example.com"
end
test "headers" do
conn = conn(:get, "/image.jpg")
conn = MyPlug.call(conn, @opts)
# Will pass if the header is present
assert_header "content_type"
# Will pass if the header value is set to the given string
assert_header "content_type", "image/jpg"
# Will pass if the header value matches the given regex
assert_header_match "content_type", ~r/\Aimage\/jpe?g\Z/
end
test "body" do
conn = conn(:get, "/")
conn = MyPlug.call(conn, @opts)
# Will pass if the response body is the given string
assert_body "complete response text"
# Will pass if the response body matches the given regex
assert_body_match ~r/complete/
end
end
Current Design Decisions
Things may always change but these are the current design decisions taken to build this library.
Convention over Configuration
Each of the assert
macros expect a variable named conn
to be bound to a Plug.Conn
.
This is definitely a questionable design decision and I'd be very happy ot get some feedback about this.
I think it's nice to have tests that are simple and concise. Is it worth providing macros accepting an extra conn
parameter?
Advanced Response Body Assertions
Assertions to match against structured response content (such as HTML or JSON) are currently out of the scope of this library.
License
Copyright 2014 Xavier Defrang
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*Note that all licence references and agreements mentioned in the plug_test_helpers README section above
are relevant to that project's source code only.