In Visual Studio Code, I see no GUI option to run all my Flutter unit tests. I have to individually select each test file, right click, and choose either 'Start debugging' or 'Start without debugging.'
When the emulator is running, I am unable unable to do the above. I cannot run any unit tests from the GUI
My unit tests are located in the test directory and all end in '_test.dart'. To get around both of the above, I can run all the unit tests by doing flutter test from the terminal, but I was wondering if there was a GUI option.
This issue does not exist on Android Studio.
Have you tried this?
https://dartcode.org/releases/v2-21/
{
"name": "All Tests",
"type": "dart",
"request": "launch",
"program": "tests/", // or test/foo for a subset of tests
}
Related
I'm trying to debug a Protractor e2e test of an Angular application. I want to start from the e2e test and stop in the application.
I set a breakpoint in the e2e test and one in an Angular component (which should be hit when running the test).
Before launching debug, both breakpoints are bound, but on debug launch the application breakpoint becomes unbound. The e2e breakpoint is hit but not the one in the Angular component.
I've tried to add sourceMap:true in my various tsconfig.json files and in launch configuration, no luck.
I compile from command line (npm run ng serve) which works when I debug e2e tests only or my application only. No .map files are generated.
I want to debug in VSCode, not in Chrome.
Launch configuration:
{
"name": "Launch e2e current file",
"type": "node",
"request": "launch",
"stopOnEntry": false,
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"args": [
"${workspaceRoot}/protractor.conf.js",
"--specs=${file}"
],
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/out-tsc-e2e/*.js"
],
"skipSourceMapSupport": true
}
Thank you.
Edit:
Here is a sample project: https://gitlab.com/group11804/project1.git
Run npm ci, npm run start-dev, in VSCode add breakpoints in app.e2e-spec.ts (test1 it()) and AppComponent.onClick() (app.component.ts), select Launch e2e current file launch configuration and hit F5.
Breakpoint in AppComponent.onClick() is not honored, debugger does not stop on it.
I am using the vscode-hack extension on visual code studio on macOS Big Sur. My settings.json includes following launch configuration:
"configurations": [
{
"name": "HHVM: Run Script",
"type": "hhvm",
"request": "launch",
"script": "${file}",
"hhvmPath": "/usr/local/bin/hhvm",
"hhvmArgs": ["--mode", "vsdebug", "--vsDebugPort", 8999],
"cwd":"${workspaceFolder}"
}
]
When I try to debug a Hack script in Visual code debugger, Visual code debugger adapter launches and immediately dies. I have verified launching hhvm with the same args from command line, and it works fine. I am following the instructions here https://github.com/slackhq/vscode-hack/blob/master/docs/debugging.md
Does anybody have any suggestions?
I am new with Flutter, and I am trying to view my new project with Android Emulator. I've installed Dart, Flutter, and Android Studio correctly, but when I try to start the project in Visual Studio (without and with debugging mode), and choosing the correct emulator I get the following error:
Your launch config references a program that does not exist. If you
have problems launching, check the "program" field in your
".vscode/launch.json" file.
I have read in the documentation that it is possible to fix this by adding:
"program": "lib/main.dart",
instead of:
program : bin/main.dart
But still does not work.
First of all, your question says you are going to run Flutter web project in android emulator.
From this, I am guessing that you are using Flutter beta version. With that version, you can't run your project on android emulator.
Second, to run Flutter project on VSCode, you need to add launch.json file for some configuration like this.
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter - Current",
"request": "launch",
"type": "dart"
}
]
}
I've been using Webstorm for a while and running protractor there is nice and smooth. Now, I was thinking to start using Visual Studio Code for test run. The only thing I am missing is Test Explorer.
So my setup: Protractor 5.4 + TypeScript 3.4 + Jasmine 3.3
I installed Test Explorer UI and Jasmine Test Explorer (1.5.0) and tried setting up launch.json and jasmine.json for it but it simply doesn't show any tests in the Test Explorer.
my jasmine.json that is located in .vscode folder inside project
{
"spec_dir": "${workspaceRoot}/tmp/specs/",
"spec_files": ["*.spec.js"],
"helpers": ["helpers/**/*.js"],
"random": false,
"seed": null,
"stopSpecOnExpectationFailure": false
}
launch.json
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "../node_modules/protractor/bin/protractor",
"stopOnEntry": false,
"args": ["${workspaceRoot}/protractor.conf.js"],
}
My issue, no tests are shown. I would like to be able to run tests from Test Explorer. Any help is much appreciated.
Just execute webdriver-manager with npx command in your project folder;
npx webdriver-manager update
I've read and tried integration testing with flutter. I followed this guide here...
https://flutter.io/docs/cookbook/testing/integration
Now, to run the integration test I have to type in the following command:
flutter drive --target=test_driver/app.dart
My question is, is there a way to automate this inside android studio so I do not have to type in the command manually. I rather just click one button and run the integration test than type the command over and over again.
I'm new in flutter over all so any suggestion will be very much appreciated. Thanks in advance.
Not sure if you found answer for your question, but I am going to post solution here. Hope it helps.
In Android Studio, open the run/edit configuration dialog and select Edit Configurations as below:
Click on + button and select Dart Command Line App configuration.
Give a name for the configuration (ex: integration.dart) and select following:
Dart file: the path of the dart file which has integration test. (ex: app_test.dart)
Working directory: root path of your project.
Environment variables: click on folder icon at extreme right in this field and create new environment variable as below:
Note that, the http url will be different in your case. In order to find out that, run the flutter command in terminal and note the observatory url displayed in the console. In my case, it was below:
flutter: Observatory listening on http://127.0.0.1:51150/
Replace it with yours and click OK.
Once you complete above steps properly and run the integration.dart configuration, you should be able to run the command from Android Studio and see the results in IDE.
I am using Visual Studio and I have created a script file integration_test.sh.
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/login_test.dart
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/register_test.dart
..
To execute the test. I just run bash scripts/integration_test.sh
I am also trying to add on launch.json with task.json still could not figure it out. I will update the answer once everything is working.
Code for launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter Dev",
"program": "lib/main_dev.dart",
"request": "launch",
"type": "dart"
},
...
{
"name": "Flutter Integration Test",
"preLaunchTask": "IntegrationTest",
}
]
}
Code for task.json
{
"version": "0.2.0",
"tasks":[
{
"taskName": "IntegrationTest",
"command": "scripts/integration_test.sh",
"isShellCommand": true
}
]
}
Setting up a Run Config with for flutter drive using "Dart Command Line App" requires a VM_SERVICE_URL Environment. If you'd like to let flutter drive create their own VM instance dynamically, you can configure the flutter drive command as an 'External Tool' in Android Studio, and configure created External Tool to run 'Before launch'. Note that the path set on 'Program' points to the Flutter SDK.
You can check this GitHub thread for more details.