Data provider
Run multiple test cases for a given function (aka "data provider").
Arguments:
func_name: The name of the function to be tested.args_per_row: (Optional) The number of arguments in each row of theTEST_CASESarray, defaults to1. Last argument is always the expected value.
Global Variables:
TEST_CASES: An array containing test cases with their expected values.
Examples:
To run a function add_numbers with TEST_CASES containing three arguments per
row, you can call dataprovider_run like so:
# Function to test.
add_numbers() {
echo "$(($1 + $2))"
}
@test "Test add_numbers" {
# Numbers: first two are inputs, last is expected output.
TEST_CASES=(
1 2 3
4 5 9
)
dataprovider_run "add_numbers" 3
}