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

Increase test coverage to utils.dart #1178

Conversation

victordmp
Copy link
Contributor

@victordmp victordmp commented Nov 16, 2022

Initial Proposed

  • Improve test coverage to utils.dart on macOs.

My Proposed

  • Improve the test suite coverage of filePathsToPlatformFiles().
    • Create two more test cases.
  • Create test suite for runExecutableWithArguments() function.
    • There are no tests for it in file_picker_utils_test.dart.

Objective

  • go from 52.2% coverage to 100% coverage for the utils file functions

Setup

  • macOs Ventura 13.0

Fixes

Improve the test suite coverage of filePathsToPlatformFiles().

  • Test 1:
    • Coverage Before:
    Screenshot 2022-11-16 at 14 57 48 * **Added test case**
test(
    'should tranform a list of file paths containing a path into a list of PlatformFiles',
    () async {
  final filePaths = <String>['test'];

  final platformFiles = await filePathsToPlatformFiles(
    filePaths,
    true,
    false,
  );

  expect(platformFiles.length, equals(filePaths.length));
});
  • Coverage After:
    Screenshot 2022-11-16 at 15 00 14

  • Test 2:

    • Coverage Before:
    Screenshot 2022-11-16 at 15 00 14
    • Added test case
test(
    'should transform a list of file paths containing a valid path into a list of PlatformFiles',
    () async {
  final filePaths = <String>['test/test_files/test.pdf'];

  final platformFiles = await filePathsToPlatformFiles(
    filePaths,
    false,
    true,
  );

  expect(platformFiles.length, equals(filePaths.length));
});
  • Coverage After:
    Screenshot 2022-11-16 at 15 02 19

Create test suite for runExecutableWithArguments() function.

  • Coverage Before:

Screenshot 2022-11-16 at 15 02 19

  • Added test case
group('runExecutableWithArguments()', () {
  test('should catch an exception when sending an empty filepath', () async {
    final filepath = '';

    expect(
      () async => await isExecutableOnPath(filepath),
      throwsA(isA<Exception>()),
    );
  });
});
  • Coverage After:

Screenshot 2022-11-16 at 15 04 01

Checking the changes

  • Update CHANGELOG.

Copy link
Owner

@miguelpruivo miguelpruivo left a comment

Choose a reason for hiding this comment

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

LGTM, could you please update the version in both changelog and pubspec to 5.2.4?

@victordmp
Copy link
Contributor Author

LGTM, could you please update the version in both changelog and pubspec to 5.2.4?

Sorry for not making the requested changes. After creating the pull request, I no longer tracked the progress. Thank you for reviewing this pull request.

@philenius
Copy link
Collaborator

@victordmp thank you for your valuable contribution. I included your two commits in #1261

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.

None yet

3 participants