Skip to content

Enhanced enums in Flutter don't get covered #505

@alberto-sf

Description

@alberto-sf

I have this enum in a file:

enum VegaRadioSize {
  small(27, 18),
  large(36, 22);
  final double normalSize;
  final double pressedSize;
  const VegaRadioSize(this.normalSize, this.pressedSize);
}

It is tested in this way:

group('VegaRadioSize test', () {
    test('Smoke', () {
      expect(VegaRadioSize.values.length, equals(2));
    });

    test('Large test', () {
      expect(VegaRadioSize.large.normalSize, equals(36));
      expect(VegaRadioSize.large.pressedSize, equals(VegaSpacings.space4));
    });

    test('Small test', () {
      expect(VegaRadioSize.small.normalSize, equals(27));
      expect(VegaRadioSize.small.pressedSize, equals(VegaSpacings.space3));
    });
  });

When running flutter test --coverage, the following result appears:

Screenshot 2022-08-12 at 19 56 44

Is this expected? How can I fully cover the enum?


This (#493) issue was closed by @liamappelbe but I think the problem isn't yet solved.

Here's my setup:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.5 21G72 darwin-arm, locale
en-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version
32.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

And Dart:

Dart SDK version: 2.17.5 (stable) (Tue Jun 21 11:05:10 2022 +0200) on "macos_arm64"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions