Skip to content

Missing main under _test.dart file #2567

@FMorschel

Description

@FMorschel

I ran the tests in a project where I wrote the _test.dart file, but since it was a plugin, I should use test_reflective_loader. I wrote the class, but I forgot to add @reflectiveTest and the main function and tried running the tests from the terminal:

00:11 +31 -1: loading essential_lints/test\fixes\replace_with_squared_box_test.dart [E]
  Failed to load "essential_lints/test\fixes\replace_with_squared_box_test.dart":
  /C:/Users/FELIP_~1/AppData/Local/Temp/dart_test.kernel.2beb11dc/test.dart:14:42: Error: Undefined name 'main'.
        internalBootstrapVmTest(() => test.main, sendPort);
                                           ^^^^

To run this test again: C:\Users\felip_0vh5fa6\dart\bin\dart.exe test essential_lints/test\fixes\replace_with_squared_box_test.dart -p vm --plain-name "loading essential_lints/test\fixes\replace_with_squared_box_test.dart"

From inside VS Code:

Connecting to VM Service at ws://127.0.0.1:15018/jbQlmHQSBV4=/ws
Connected to the VM Service.
Failed to load "D:/dev/dart/essential_lints/essential_lints/test/fixes/replace_with_squared_box_test.dart":
/C:/Users/FELIP_~1/AppData/Local/Temp/dart_test.kernel.37e10478/test.dart:14:42: Error: Undefined name 'main'.
test.dart:14
      internalBootstrapVmTest(() => test.main, sendPort);
                                         ^^^^
package:test_core/src/runner/vm/platform.dart 290:7   VMPlatform._compileToKernel
platform.dart:290
===== asynchronous gap ===========================
package:test_core/src/runner/vm/platform.dart 260:11  VMPlatform._spawnIsolate
platform.dart:260
===== asynchronous gap ===========================
package:test_core/src/runner/vm/platform.dart 83:19   VMPlatform.load
platform.dart:83
===== asynchronous gap ===========================
package:test_core/src/runner/loader.dart 244:27       Loader.loadFile.<fn>
loader.dart:244
===== asynchronous gap ===========================
package:test_core/src/runner/load_suite.dart 104:21   new LoadSuite.<fn>.<fn>
load_suite.dart:104
✖ loading D:/dev/dart/essential_lints/essential_lints/test/fixes/replace_with_squared_box_test.dart

Exited (1).

Basically, this is trying to say I have no main. But I feel like this should be a very specific message.

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