question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test files main is run even when specific launch config is selected and invoked via menu

See original GitHub issue

If you have a Dart unit test file open with a main function, even if you click the “green arrow” in the Runs and Debug (as in screenshot below) to try to run a specific Flutter launch config, it will still run the tests in the tests files main() instead of the selected launch config.

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Oct 4, 2022

Yep, you should always specify a program if you don’t want us to try to infer one from the open file/project. Generally I’d only suggest a launch config without a program if you want to be able to use F5 and have the entry point inferred, but need to set some additional args/env/etc. that wouldn’t otherwise be set by default.

Let me know if anything still doesn’t seem to work as expected!

1reaction
DanTupcommented, Sep 25, 2022

Is it the case if I have some targets set with a program I shouldn’t rely on the default behaviour of lib/main.dart being used?

Do you mean for targets without a program? If you have an explicit program it should always run that. However if you don’t have one set, the default behaviour is not to run lib/main.dart, there are a set of rules. It’s something like this:

  • If the open file is a test file, run that (being a test file usually means inside test or integration_test and ends with _test, although there are some settings to support tests outside of the test folders etc.)
  • If the open file is in bin/ or tool/, run that
  • Otherwise, locate the best project root (which may start from the open file), and then look in some default locations (bin/main.dart, lib/main.dart)

So generally, if you want to always run a specific file, you should add an explicit program. Otherwise, you’ll get our best guess at what you want to run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I run a single test using Jest? - Stack Overflow
Another way is to run tests in watch mode, jest --watch , and then press P to filter the tests by typing the...
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Debugging - golang/vscode-go - GitHub
Open a file to debug (either package main source file or the test file) in the editor, and select the Run and Debug...
Read more >
Editing Launch Configurations
Open a Launch Configuration Dialog ; Select Run → Run Configurations from the top-level menu (or Run → Debug Configurations or Run →...
Read more >
Configure unit tests by using a .runsettings file - Microsoft Learn
To specify a run settings file in the IDE, select Test > Select Settings File. Browse to and select the .runsettings file. Select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found