We are releasing assert_value. assert_value is ExUnit’s assert on steroids that writes and updates tests for you.
You can use
assert_value instead of ExUnit’s
assert. It makes Elixir tests interactive and lets you create and update expected values with a single key press.
Here is a simple example. Start with a broken test:
assert_value "foo\n" == """ bar """
Run tests as usual. assert_value will show the diff and ask you what to do. Here we like the new value and tell assert_value to accept it:
~/> mix test test/my_test.exs:6:"test example" assert_value "foo\n" == "bar\n" failed -bar +foo Accept new value? [y,n,?] y . Finished in 1.0 seconds 1 test, 0 failures
Your test will be automatically updated:
assert_value "foo\n" == """ foo """
- makes writing tests easier by automatically generating expected values
- makes maintaining tests and refactoring code much easier
- improves test readability
We appreciate all feedback.
P.S. We also have a ruby version of this library. The elixir version turned out to be a substantial improvement over the ruby version. Because of macros we are able to use more natural, composable, and extensible syntax. Another huge advantage is async tests and assert_value supports them fully.