Skip to content

debugging with VSCode #325

Open
Open

Description

@mdelapenya

Is it possible to debug a godog scenario using breakpoints with VSCode? I could not find a way to do it, and I wonder if anybody had luck in doing that.

Activity

  1. MetalBlueberry commented on Jul 13, 2020

    @MetalBlueberry

    what prevents you from running the code as regular go tests? just open the *_test.go file and press F5. everything should work.
    You can place regular breakpoints in the implementation.

  2. yuseferi commented on Nov 4, 2020

    @yuseferi

    how about the goland?
    because there is no main func there, the run is not activated by default.
    how can I debug godog in goland?

  3. paschelino commented on Apr 15, 2021

    @paschelino

    And how would you do this with delve?

  4. stevecager commented on May 13, 2022

    @stevecager

    I can run a scenario in debug mode in Goland using this run config:

    image

  5. vearutop commented on May 20, 2022

    @vearutop
    Contributor

    You can add a regular test that invokes godog and then use your IDE capabilities to run/debug tests.

    func TestFeatures(t *testing.T) {
      suite := godog.TestSuite{
        ScenarioInitializer: InitializeScenario,
        Options: &godog.Options{
          Format:   "pretty",
          Paths:    []string{"features"},
          TestingT: t, // Testing instance that will run subtests.
        },
      }
    
      if suite.Run() != 0 {
        t.Fatal("non-zero status returned, failed to run feature tests")
      }
    }
    

    image

  6. waytocypress commented on Jul 14, 2022

    @waytocypress

    set environment as GODOG_DEUG= true in the debug configuration and add break points where ever you want

  7. witgaw commented on Nov 24, 2022

    @witgaw

    Just add a debug configuration similar to that to your launch.json:

          {
              "name": "Debug .feature test",
              "type": "go",
              "request": "launch",
              "mode": "test",
              "program": "${workspaceFolder}/some_path/main_test.go",
              "args": [
                  "--godog.format",
                  "pretty",
                  "-test.run",
                  "${workspaceFolder}/some_path/some_subpath/your_feature_test.feature"
              ]
          },
    

    You can add a line number where the Scenario: is defined to debug a single scenario from file, e.g. your_feature_test.feature:102

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址