test: bring 6 packages to 100% line coverage#38
Merged
Conversation
Covers timer_button, html_rich_text, cli_core, connectivity_wrapper, morse_tap, and ns_utils. Adds 304 tests total, all passing. Minor production adjustments to enable testing: - cli_core: extract stdoutTerminalColumnsResolver as a @VisibleForTesting seam so the wrap()'s non-length branch is reachable from tests. - morse_tap: add @VisibleForTesting debugHapticSupportedOverride on HapticUtils so haptic paths can be exercised off-device. - connectivity_wrapper: narrow 3 truly-unreachable-in-tests branches with coverage:ignore pragmas (kIsWeb, sock?.destroy, timer?.cancel). - ns_utils: widen 3 'on Exception catch' to 'catch' (json encoding errors are Error-typed so the previous catches were dead); refactor List.toComaSeparatedValues so the catch is reachable; mark the private Sizes._() constructor with coverage:ignore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI build job failed on `dart format --set-exit-if-changed` and `dart analyze --fatal-infos` for the test-coverage changes. - Reformat 9 test files to satisfy dart format. - Remove unnecessary/unused imports flagged by the analyzer (mason_logger in cli_core tests, meta in morse_tap haptic_utils, cupertino and ns_utils/src.dart in ns_utils tests). - Suppress unrelated_type_equality_checks on the intentional HapticConfig == String inequality assertion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 67 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
timer_button,html_rich_text,cli_core,connectivity_wrapper,morse_tap, andns_utils, bringing all six to 100% line coverage.@visibleForTestinghooks) and a few narrowcoverage:ignorepragmas on genuinely unreachable-in-tests branches (web-only code, defensive cleanups in error catch blocks).on Exception catchblocks inns_utilstocatchbecausejson.encodethrowsError-typed objects — the previouson Exceptioncatches were dead code.Coverage results
timer_buttonhtml_rich_textcli_coreconnectivity_wrappermorse_tapns_utilsProduction-code changes (minimal, test-enablers)
cli_core/logger_extension.dart: extractedstdoutTerminalColumnsResolveras a@visibleForTestingfunction pointer so tests can stub the terminal-columns lookup.morse_tap/haptic_utils.dart: added@visibleForTesting debugHapticSupportedOverrideso haptic paths work off-device.connectivity_wrapper/connectivity_wrapper.dart:// coverage:ignore-lineon thekIsWebbranch of_defaultAddresses, asock?.destroy()cleanup that is unreachable in practice, and atimer?.cancel()that only runs when_maybeEmitStatusUpdateis passed aTimer(the one-shotTimerconstructor never does).ns_utils/extensions/list.dart,extensions/map.dart,extensions/context.dart,methods/conversion.dart: swapon Exception catch→catchwhere the thrown type isError-typed (JsonUnsupportedObjectError, etc.).ns_utils/extensions/list.dart: refactortoComaSeparatedValuesso thecatchis reachable (previously the initializerdata = toString()threw before enteringtry).ns_utils/utils/sizes.dart:// coverage:ignore-lineon the privateSizes._()constructor.Remaining work (not in this PR)
5 packages still need coverage work:
ns_firebase_utils,ns_intl_phone_input,dzod,nonstop_cli,contact_permission.Test plan
cd packages/timer_button && flutter test— 31 tests passcd packages/html_rich_text && flutter test— 21 tests passcd packages/cli_core && dart test— 27 tests passcd packages/connectivity_wrapper && flutter test— 57 tests passcd packages/morse_tap && flutter test— 70 tests passcd packages/ns_utils && flutter test— 98 tests passmelos lint— format + analyze clean🤖 Generated with Claude Code