power_assert alternatives and similar packages
Based on the "Testing" category.
Alternatively, view power_assert alternatives based on common mentions on social networks and blogs.
-
ex_machina
Flexible test factories for Elixir. Works out of the box with Ecto and Ecto associations. -
hound
Elixir library for writing integration tests and browser automation. -
wallaby
Wallaby helps test your web applications by simulating user interactions concurrently and manages browsers. -
proper
PropEr (PROPerty-based testing tool for ERlang) is a QuickCheck-inspired open-source property-based testing tool for Erlang. -
bypass
Bypass provides a quick way to create a mock HTTP server with a custom plug. -
mix_test_watch
Automatically run your Elixir project's tests each time you save a file. -
ExVCR
HTTP request/response recording library for Elixir, inspired by VCR. -
StreamData
Data generation and property-based testing for Elixir. 🔮 -
excheck
Property-based testing library for Elixir (QuickCheck style). -
amrita
A polite, well mannered and thoroughly upstanding testing framework for Elixir. -
ponos
Ponos is an Erlang application that exposes a flexible load generator API. -
shouldi
Elixir testing libraries with nested contexts, superior readability, and ease of use. -
chaperon
An HTTP service performance & load testing framework written in Elixir. -
katt
KATT (Klarna API Testing Tool) is an HTTP-based API testing tool for Erlang. -
FakeServer
FakeServer integrates with ExUnit to make external APIs testing simpler -
mecks_unit
A package to elegantly mock module functions within (asynchronous) ExUnit tests using meck. -
factory_girl_elixir
Minimal implementation of Ruby's factory_girl in Elixir. -
test_selector
A set of test helpers that make sure you always select the right elements in your Phoenix app. -
double
Create stub dependencies for testing without overwriting global modules. -
mix_erlang_tasks
Common tasks for Erlang projects that use Mix. -
cobertura_cover
Writes a coverage.xml from mix test --cover file compatible with Jenkins' Cobertura plugin. -
mix_test_interactive
Interactive test runner for mix test with watch mode. -
ex_unit_fixtures
A library for defining modular dependencies for ExUnit tests. -
ElixirMock
(alpha) Sanitary mock objects for elixir, configurable per test and inspectable -
ExopData
A library that helps you to write property-based tests by providing a convenient way to define complex custom data generators.
Scout APM - Leading-edge performance monitoring starting at $39/month
Do you think we are missing an alternative of power_assert or a related project?
README
Power Assert
Power Assert makes test results easier to understand, without changing your ExUnit test code.
Example test is here:
test "Enum.at should return the element at the given index" do
array = [1, 2, 3, 4, 5, 6]; index = 2; two = 2
assert array |> Enum.at(index) == two
end
Here is the difference between ExUnit and Power Assert results:
Enjoy :muscle: !
Installation
Add Power Assert to your mix.exs
dependencies:
defp deps do
[{:power_assert, "~> 0.2.0", only: :test}]
end
and fetch $ mix deps.get
.
Usage
Replace use ExUnit.Case
into use PowerAssert
in your test code:
## before(ExUnit)
defmodule YourAwesomeTest do
use ExUnit.Case # <-- **HERE**
end
## after(PowerAssert)
defmodule YourAwesomeTest do
use PowerAssert # <-- **REPLACED**
end
Done! You can run $ mix test
.
Use with ExUnit.CaseTemplate
Insert use PowerAssert
with ExUnit.CaseTemplate.using/2
macro:
## before(ExUnit.CaseTemplate)
defmodule YourAwesomeTest do
use ExUnit.CaseTemplate
end
## after(PowerAssert)
defmodule YourAwesomeTest do
use ExUnit.CaseTemplate
# add the following
using do
quote do
use PowerAssert
end
end
end
protip: useful command to replace use ExUnit.Case
$ git grep -l 'use ExUnit\.Case' | xargs sed -i.bak -e 's/use ExUnit\.Case/use PowerAssert/g'
How to use with other framework depending on ExUnit such as ExSpec or ShouldI
ExSpec
Append use PowerAssert
after use ExSpec
:
defmodule ExSpecBasedTest do
use ExSpec
use PowerAssert # <-- append
describe "describe" do
it "it" do
assert something == "hoge"
end
end
end
See also: test/ex_spec/ex_spec_test.exs
ShouldI
Append use PowerAssert
after use ShouldI
:
defmodule ShouldTest do
use ShouldI
use PowerAssert # <-- append
should "inside should" do
assert something == "hoge"
end
end
See also: test/should/should_test.exs
API
Only provide assert
macro:
assert(expression, message \\ nil)
Dependencies
- ExUnit
Limitation
- NOT SUPPORTED
- match expression ex:
assert List.first(x = [false])
- fn expression ex:
assert fn(x) -> x == 1 end.(2)
- :: expression ex:
<< x :: bitstring >>
- this means string interpolations also unsupported ex:
"#{x} hoge"
- sigil expression ex:
~w(hoge fuga)
- quote arguments ex:
assert quote(@opts, do: :hoge)
- case expression
- get_and_update_in/2, put_in/2, update_in/2, for/1
- <<>> expression includes attributes
<<@x, "y">>; <<x :: binary, "y">>
__MODULE__.Foo
- many macros maybe caught error...
- match expression ex:
Resources
Author
Takayuki Matsubara (@ma2ge on twitter)
License
Distributed under the Apache 2 License.
Check [LICENSE](LICENSE) files for more information.
*Note that all licence references and agreements mentioned in the power_assert README section above
are relevant to that project's source code only.