Skip to content

Code covarage isn't collected if the packages folder name does not match the package name in pubspec.yaml #5706

@sma

Description

@sma

Since v3.118 (I'm at v3.118.1 now), my project lost the ability to generate code coverage in Flutter projects. I'm pretty sure that before that version, it worked. Unfortunately, with that update, I also updated Flutter to 3.35.

I created the following log file which I redacted, hoping it will help to pin down the issue.

I'm selecting a single test file, clicking the coverage icon.

I'd expect code coverage for that file, but don't get any.

!! ⚠️ PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING ⚠️ !!
Dart Code extension: 3.118.1
Flutter extension: 3.118.0 (activated)

App: Visual Studio Code
App Host: desktop
Version: mac 1.104.0

Workspace type: Flutter (LSP)
Workspace name: ...

Dart (3.9.2): /Users/sma/Work/flutter/bin/cache/dart-sdk
Flutter (3.35.3): /Users/sma/Work/flutter (No device)

...

[12:18:20] [General] [Info] Debug session starting...
    {
        "suppressPrompts": false,
        "name": "... Tests (iPhone 16 Pro)",
        "noDebug": true,
        "request": "launch",
        "type": "dart",
        "args": [],
        "cwd": "/Users/sma/Work/<appname>",
        "coverageFilePath": "/var/folders/hb/vckjfn4x5wv5gyk2nml5y3pc0000gn/T/flutter-coverage-90c7.lcov",
        "expectSingleTest": false,
        "program": "/Users/sma/Work/<appname>/test/unit/data_exception_test.dart",
        "toolArgs": [
            "--coverage",
            "--branch-coverage",
            "--coverage-path",
            "/var/folders/hb/vckjfn4x5wv5gyk2nml5y3pc0000gn/T/flutter-coverage-90c7.lcov",
            "--coverage-package",
            "<appname>",
            "-d",
            "2FBE561C-2E8E-406B-BE4C-7BA99F0571C4"
        ],
        "dartCodeDebugSessionID": "session-4d4d9",
        "projectRootPath": "/Users/sma/Work/<appname>",
        "deviceId": "2FBE561C-2E8E-406B-BE4C-7BA99F0571C4",
        "deviceName": "iPhone 16 Pro (ios)",
        "toolEnv": {
            "FLUTTER_HOST": "VSCode",
            "PUB_ENVIRONMENT": "vscode.dart-code",
            "FLUTTER_ROOT": "/Users/sma/Work/flutter"
        },
        "sendLogsToClient": true,
        "sendCustomProgressEvents": true,
        "allowAnsiColorOutput": true,
        "additionalProjectPaths": [
            "/Users/sma/Work/<appname>"
        ],
        "vmAdditionalArgs": [],
        "vmServicePort": 0,
        "dartSdkPath": "/Users/sma/Work/flutter/bin/cache/dart-sdk",
        "maxLogLineLength": 2000,
        "debugSdkLibraries": false,
        "debugExternalPackageLibraries": false,
        "showDartDeveloperLogs": true,
        "evaluateGettersInDebugViews": true,
        "showGettersInDebugViews": true,
        "evaluateToStringInDebugViews": true,
        "flutterSdkPath": "/Users/sma/Work/flutter",
        "useInspectorNotificationsForWidgetErrors": false,
        "showMemoryUsage": false,
        "debuggerType": 3
    }

I checked ls /var/folders/hb/vckjfn4x5wv5gyk2nml5y3pc0000gn/T/*.lcov and there are plenty of files, however the file in question is empty!

If I run flutter test test/unit/data_exception_test.dart --coverage --branch-coverage manually, I get an coverage/lcov.info file as expected. If I add the --coverage-package option, that file is now empty. The tests run in both cases.

The <appname> is correct, though.

Perhaps this is a bug in the flutter tooling?

update: I think, I pinned down the problem. <appname> aka package name and the folder name differ in one character. The plugin passes the foldername instead of the package name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions