ValueVariant<T> class
A TestVariant that runs separate tests with each of the given values.
To use this variant, define it before the test, and then access currentValue inside the test.
The values are typically enums, but they don't have to be. The toString
for the given value will be used to describe the variant. Values will have
their type name stripped from their toString
output, so that enum values
will only print the value, not the type.
This example shows how to set up the test to access the currentValue. In
this example, two tests will be run, one with
link
value1
, and one with
value2
. The test with value2
will fail. The names of the tests will be:
Test handling of TestScenario (value1)
Test handling of TestScenario (value2)
enum TestScenario {
value1,
value2,
value3,
}
final ValueVariant<TestScenario> variants = ValueVariant<TestScenario>(
<TestScenario>{TestScenario.value1, TestScenario.value2},
);
void main() {
testWidgets('Test handling of TestScenario', (WidgetTester tester) async {
expect(variants.currentValue, equals(TestScenario.value1));
}, variant: variants);
}
- Inheritance
-
- Object
- TestVariant<
T> - ValueVariant
Constructors
-
ValueVariant(Set<
T> values) - Creates a ValueVariant that tests the given values.
Properties
- currentValue → T?
-
Returns the value currently under test.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Set<
T> -
Returns an iterable of the variations that this test dimension represents.
final
Methods
-
describeValue(
T value) → String -
Returns the string that will be used to both add to the test description, and
be printed when a test fails for this variation.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setUp(
T value) → Future< T> -
A function that will be called before each value is tested, with the
value that will be tested.
override
-
tearDown(
T value, covariant T memento) → Future< void> -
A function that is guaranteed to be called after a value is tested, even
if it throws an exception.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited