Skip to content

Debug configurations for tests #1901

Closed

Description

@alan-knight

I'd like to be able to specify configurations for tests. My motivating example are things like https://github.com/dart-lang/webdev/blob/5d964f2e0c3b891b99eb496f933629133e8ed2d9/dwds/test/fixtures/context.dart#L95

Many of the tests need to run Chrome with a simple application and a debug port open and then test debug commands against it. Normally these are run headless, but for debugging it's useful to have Chrome visible. Right now this is controlled using an environment variable, but that's awkward to change. If we had a debug configuration that could pass an argument, or set an environment variable, or otherwise indicate something that was visible to the running test, that would be better.

Activity

  1. added this to the v3.4.0 milestone on Aug 1, 2019
  2. added
    in testingRelates to test execution of Dart/Flutter tests for end users
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Aug 1, 2019
  3. DanTup commented on Aug 1, 2019

    @DanTup
    Member

    Some notes from our discussion in Gitter:


    Some possible ideas:

    1. Dart-Code always sets an env variable saying whether it's debug or run mode
    2. If you create a launch.json config with some well-known names (for ex. "Run Test" and "Debug Test") we use them as templates for running/debugging tests
    3. We have some other config that lets you add custom test configs that pass arguments, for ex. if you added one called "Run in Browser" and "Debug in Browser", then the Code Lens links and the context menu in the test runner should include them (so you'd have Run Test, Debug Test, Run in Browser, Debug in Browser). This couldn't easily be test-specific, but you could configure it in Workspace Settings (the project-local .vscode/settings.json file)

    These seem reasonable generic, and 2/3 may help with some plumbing towards #1197 too (that's for the -p chrome flag where you run the tests actually in the browser using package:test).


    2.5 Similar to (2) above, but instead of using names, we add some property that flags a config to be a template for tests, eg.:

    {
      type: "dart",
      name: "Debug in Browser",
    
      // "run-test" | "debug-test" | undefined
      // run-test: shows in codelens/context menu and will run without debugger
      // debug-test: shows in codelens/context menu and will run with debugger
      // undefined: doesn't show anywhere - just a normal launch config
      templateFor: "run-test",
    
      args: [/*...*/],
      env: {/*...*/},
    }
  4. added a commit that references this issue on Aug 6, 2019
    2ee6352
  5. DanTup commented on Aug 6, 2019

    @DanTup
    Member

    @alan-knight I've added support for what was discussed above - details/example are here:

    #1916

    If you'd like to try it out to give feedback before it goes into a release, you can download the vsix file from here:

    https://github.com/Dart-Code/Dart-Code/releases/tag/v3.3.1-alpha.1

    Then run the Install Extension from VSIX command in VS Code, and locate the vsix file you downloaded. Then click the Reload prompt (you might not get one if you didn't already have a Dart project open).

    (If you stick with this build, it'll automatically update to the next stable build when published, so you don't need to worry about uninstalling/going back unless you hit issues with it - in which case please let me know!).

  6. DanTup commented on Aug 6, 2019

    @DanTup
    Member

    Oh, I forgot to mention that currently this only shows up in Code Lens links and not in the context menu for the test runner - that's a limitation of VS Code I've filed a feature request for, but not sure we're likely to see soon.

  7. added a commit that references this issue on Aug 19, 2019
    e41cb3f
  8. added a commit that references this issue on Aug 20, 2019
    0ac39fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in testingRelates to test execution of Dart/Flutter tests for end usersis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions