annotation Testify::Test::Data

Overview

Provides the data source to a specific test case (test_ method).

Example:

class UserTest < Testify::Test
  @[Data("get_model_values")]
  def test_create(values, expected)
    user = User.create(values)
    user.should be_a User
    user.to_h should eq expected
  end

  # `Data` source.
  def get_model_values : Hash
    {
      "username" => "foo",
      "email"    => "[email protected]",
      # ...
    }
  end
end

See data-driven testing.

Defined in:

testify.cr