-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Rework v2 #18
✨ Rework v2 #18
Conversation
… And class is const
// Test containing a list of enums | ||
|
||
// enum TestEnum { | ||
// one(3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this example of the enum has to be here.
}), | ||
(int value) async { | ||
final millis = DateTime.now().millisecondsSinceEpoch; | ||
await Future<void>.delayed(Duration(milliseconds: value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually time awaited? Can't we use a test time skip method? Or at least just don't include this as an example as it seems bad practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added note about bad pratice
[this], | ||
TestOptions( | ||
( | ||
values: [this], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an array? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this extension is used on a list of single values. For example:
parameterizedTest('singel values', [1,2,3], (int value) {...});
The ValueWithTestOptions
expects a list of values. Also the Function.apply
expects a list of arguments even if there is only 1 argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah got it!
9.0, | ||
]; | ||
|
||
final result = pTest.makeDescription(baseDescription, 1, values, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we put a complex object with a custom .tostring in here, is that called for building the description? Can we test that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test. This is only sort of a thing when using the custom description builder. Normally the description is passed to the group
test function which handles this out of the box. Also the custom description builder returns a Object which group
will resolve.
], | ||
(int value, String value2) => value + value2.length, | ||
), | ||
throwsA(isA<ParameterizedError>()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that there is a TypeError; but that error is not from the parameterizedTest. What whould happen then? Can we detect it and in that case rethrow the type error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added check to see if error is from within the test body.
…peErrors not caught when from inside the test body
extension StackTraceExtension on StackTrace { | ||
/// Returns `true` if the stack trace is from within a test body | ||
bool get isInsideTestBody { | ||
final trace = Trace.from(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow fancy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice changes Job! Good work! :jobapproves:
New and improved inner workings of the library.
The new version makes it easier to use. No more need for specifying the extract amount of parameters you want to use!
Work in progress:
No csv support added but added reference and example by using csv package.