test_in_case

Creator: coderz1093

Last updated:

0 purchases

test_in_case Image
test_in_case Images

Languages

Categories

Add to Cart

Description:

test in case

test_in_case #

A dart test utility for creating variations
of the same test using multiple cases. Write the testing logic once and
provide a list of cases to test.
Inspired by jest-in-case.

Installation #
dart pub add test_in_case --dev

OR

flutter pub add test_in_case --dev
copied to clipboard
Usage #
Import the test_in_case package. Use the cases function to define the tests.
It takes in three parameters:

title: The title of the group of tests.
cases: A list of TestCase objects.
tester: Pass a the testing logic as a callback which will be called for each
test case. The test case object is passed to the callback as an argument.

Call the cases function with a type parameter(cases<T>), which will be used
as the type of the test case in the TestCase object.
import 'package:test_in_case/test_in_case.dart';

cases<int>(
title: 'Even Numbers'
cases: [1, 2, 3]
.map(
(number) => TestCase(
name: '$number is even',
testCase: number,
),
)
.toList(),
tester: (testCase) => expect(testCase % 2 ==0, true);
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.