A utility for defining eminently readable parameterized (or example-based) tests in Elixir
MIT License
Adds a new param_feature
macro, which wraps Wallaby's feature
tests
the same way param_test
wraps ExUnit's test
.
(While you can use the plain param_test
macro in a test module that
contains use Wallaby.Feature
, doing so will break some Wallaby features
including screenshot generation on failure.)
Moves the parse_examples/2
function, an implementation detail for the
param_test
macro, into a new private module ParameterizedTest.Parser
.
Full Changelog: https://github.com/s3cur3/parameterized_test/compare/v0.3.1...v0.4.0
Published by s3cur3 3 months ago
Bug fix to accept more unquoted strings, including those that have Elixir delimiters in them like quotes, parentheses, etc.
Published by s3cur3 3 months ago
This is a quality of life improvement for avoiding needing to add noise to string cells:
param_test "supports unquoted strings",
"""
| value | unquoted string |
| 1, 2, 3 | The value is 1 |
""",
%{value: value, "unquoted string": unquoted} do
assert value == "1, 2, 3" and unquoted == "The value is 1"
end
If you supply a column named description
, test_description
, or test_desc
, we'll use that in the test name rather than simply dumping the values from the row in the test table. This lets you provide more human-friendly descriptions of why the test uses the values it does.
A trivial example (which also takes advantage of the support for unquoted strings):
param_test "failing test",
"""
| value | description |
| 1 | The value is 1 |
""",
%{value: value} do
assert value == 2
end
When you run this, the error will include the description ("The value is 1") in the test name:
1) test failing test - The value is 1 (MyAppTest)
test/my_app_test.exs:8
Assertion with == failed
code: assert value == 2
left: 1
right: 2
stacktrace:
test/my_app_test.exs:14: (test)
This is useful for communication with stakeholders, or for understanding what went wrong when a test fails.
Published by s3cur3 3 months ago
There are two new features in this release thanks to new contributor @axelson:
Full Changelog: https://github.com/s3cur3/parameterized_test/compare/v0.1.0...v0.2.0
Published by s3cur3 4 months ago
Renamed the package to ParameterizedTest
, with the accompanying macro param_test
. (Why not parameterized_test
? It's longer, harder to spell, and there are a lot of other accepted spellings, including "parameterised," "parametrized," and "parametrised.")
Added support for hand-rolled lists of parameters, like:
param_test "shipping policy matches the web site",
[
# Items in the parameters list can be either maps...
%{spending_by_category: %{pants: 29_99}, coupon: "FREE_SHIP"},
# ...or keyword lists
[spending_by_category: %{shoes: 19_99, pants: 29_99}, coupon: nil]
],
%{spending_by_category: spending_by_category, coupon: coupon} do
...
end
Added experimental support for populating test parameters from CSV and TSV files. Eventually I'd like to extend this to other sources like Notion documents. (Feedback welcome—just open an issue!)
Published by s3cur3 8 months ago
Initial release