All Projects → ma2gedev → Power_assert_ex

ma2gedev / Power_assert_ex

Licence: other
Power Assert in Elixir. Shows evaluation results each expression.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Power assert ex

Assert
A collection of convenient assertions for Swift testing
Stars: ✭ 69 (-65.67%)
Mutual labels:  testing-tools, assert
tressa
Little test utility
Stars: ✭ 18 (-91.04%)
Mutual labels:  testing-tools, assert
Vstest Docs
Documentation for the Visual Studio Test Platform.
Stars: ✭ 165 (-17.91%)
Mutual labels:  testing-tools
Hitchhiker
a Restful Api test tool
Stars: ✭ 2,175 (+982.09%)
Mutual labels:  testing-tools
Garden
Automation for Kubernetes development and testing. Spin up production-like environments for development, testing, and CI on demand. Use the same configuration and workflows at every step of the process. Speed up your builds and test runs via shared result caching.
Stars: ✭ 2,289 (+1038.81%)
Mutual labels:  testing-tools
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+882.59%)
Mutual labels:  testing-tools
Botium Core
The Selenium for Chatbots - Bots Testing Bots
Stars: ✭ 181 (-9.95%)
Mutual labels:  testing-tools
Resumable Assert
Assert replacement to continue execution in debugger
Stars: ✭ 157 (-21.89%)
Mutual labels:  assert
Charlatan
Go Interface Mocking Tool
Stars: ✭ 195 (-2.99%)
Mutual labels:  testing-tools
Mocktopus
Mocking framework for Rust
Stars: ✭ 179 (-10.95%)
Mutual labels:  testing-tools
Tork
💞 Tests your Ruby code, in parallel, as you change it
Stars: ✭ 185 (-7.96%)
Mutual labels:  testing-tools
Jwt Hack
🔩 jwt-hack is tool for hacking / security testing to JWT. Supported for En/decoding JWT, Generate payload for JWT attack and very fast cracking(dict/brutefoce)
Stars: ✭ 172 (-14.43%)
Mutual labels:  testing-tools
Nunit Console
NUnit Console runner and test engine
Stars: ✭ 168 (-16.42%)
Mutual labels:  testing-tools
Debug assert
Simple, flexible and modular assertion macro.
Stars: ✭ 181 (-9.95%)
Mutual labels:  assert
Ppk assert
PPK_ASSERT is a cross platform drop-in & self-contained C++ assertion library
Stars: ✭ 164 (-18.41%)
Mutual labels:  assert
Swiftpowerassert
Power Assert in Swift. Provides descriptive assertion messages.
Stars: ✭ 191 (-4.98%)
Mutual labels:  assert
Chromogen
UI-driven Jest test-generation package for Recoil selectors
Stars: ✭ 164 (-18.41%)
Mutual labels:  testing-tools
Acutest
Simple header-only C/C++ unit testing facility.
Stars: ✭ 170 (-15.42%)
Mutual labels:  testing-tools
Environmentoverrides
QA assistant for a SwiftUI app: change the color scheme, accessibility settings, and localization on the fly!
Stars: ✭ 181 (-9.95%)
Mutual labels:  testing-tools
Bats Core
Bash Automated Testing System
Stars: ✭ 2,820 (+1302.99%)
Mutual labels:  testing-tools

Power Assert

hex.pm version hex.pm daily downloads hex.pm weekly downloads hex.pm downloads Build Status License

Power Assert makes test results easier to understand, without changing your ExUnit test code.

Demo

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:

Difference between ExUnit and Power Assert

Enjoy 💪 !

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

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

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...

Resources

Author

Takayuki Matsubara (@ma2ge on twitter)

License

Distributed under the Apache 2 License.

Check LICENSE files for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].