Function inside function
Is there a way for the coverage to detect already tested functions inside other functions?


If I put the function call directly into the return, then, the return becomes also not covered.
@JeanPSF I can't reproduce this based on just these small code snippets. Can you give me more context, or better yet, post a minimal repro program?
The tests I am running are these (they are passing).
group('On retrieving User Preferences tests => ', () {
UserPreferences? failUserPreferencesMockResult;
UserPreferences? successUserPreferencesResult;
setUpAll(() async {
safePrint('running user pref setUpAll!');
failUserPreferencesMockResult = await userAPI
.getUserPreferences()
.then(
(result) => userApiMock.onRetrieveUserPreferencesError,
)
.onError(
(error, stackTrace) => userApiMock.onRetrieveUserPreferencesError,
);
successUserPreferencesResult = await userAPI
.getUserPreferences()
.then(
(result) => userApiMock.onRetrieveUserPreferencesSuccess,
)
.onError(
(error, stackTrace) => userApiMock.onRetrieveUserPreferencesSuccess,
);
});
test('Error.', () {
expect(failUserPreferencesMockResult, null);
});
test('Success.', () {
expect(
successUserPreferencesResult,
isA<UserPreferences>(),
);
});
});
group('Serializers tests => ', () {
test('UserPreferences cast => OK.', () {
expect(
userAPI.userPreferencesJsonToClass(
UserPreferencesMock().userPreferencesJson,
),
UserPreferencesMock().userPreference,
);
});
});
What about the code under test? What is userAPI? Where are the UserPreferences and UserPreferencesMock defined?
What Http class are you using? In your original post, the code that isn't covered comes after awaiting the result of what looks like a network request. How are you mocking this for testing? Are you sure that missed line is actually being hit?