Skip to content
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

Merged
merged 18 commits into from
Apr 21, 2024
Merged

✨ Rework v2 #18

merged 18 commits into from
Apr 21, 2024

Conversation

Guldem
Copy link
Collaborator

@Guldem Guldem commented Apr 12, 2024

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:

  • Remove old files
  • Add new tests
  • Improve structure
  • Update documentation
  • Update dart doc

No csv support added but added reference and example by using csv package.

@Guldem Guldem marked this pull request as ready for review April 16, 2024 13:09
// Test containing a list of enums

// enum TestEnum {
// one(3),
Copy link

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));
Copy link

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?

Copy link
Collaborator Author

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],
Copy link

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? 🤔

Copy link
Collaborator Author

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.

Copy link

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);
Copy link

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?

Copy link
Collaborator Author

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>()),
Copy link

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?

Copy link
Collaborator Author

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.

@Guldem Guldem requested a review from Bassiuz April 18, 2024 07:26
extension StackTraceExtension on StackTrace {
/// Returns `true` if the stack trace is from within a test body
bool get isInsideTestBody {
final trace = Trace.from(this);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow fancy!

Copy link

@Bassiuz Bassiuz left a 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:

@Guldem Guldem merged commit 225c655 into main Apr 21, 2024
1 check passed
@Guldem Guldem deleted the feature/rework_v2 branch April 21, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants