Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugging with VSCode #325

Open
mdelapenya opened this issue Jun 30, 2020 · 7 comments
Open

debugging with VSCode #325

mdelapenya opened this issue Jun 30, 2020 · 7 comments

Comments

@mdelapenya
Copy link

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.

@MetalBlueberry
Copy link

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.

@yuseferi
Copy link

yuseferi commented Nov 4, 2020

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?

@paschelino
Copy link

And how would you do this with delve?

@stevecager
Copy link

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

image

@vearutop
Copy link
Member

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

@waytocypress
Copy link

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

@witgaw
Copy link

witgaw commented Nov 24, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants