1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
Feature: Debug your command in cucumber-test-run
As a developer
I want to use some debugger in my code and therefor need system() to execute my program
In order to find a bug
Background:
Given I use a fixture named "cli-app"
And the default aruba exit timeout is 60 seconds
Scenario: Can handle exit status 0
Given an executable named "bin/cli" with:
"""bash
#!/usr/bin/env bash
exit 0
"""
And a file named "features/debug.feature" with:
"""cucumber
Feature: Exit status in debug environment
@debug
Scenario: Run program with debug code
When I run `cli`
Then the exit status should be 0
"""
When I successfully run `cucumber`
Then the features should all pass
Scenario: Can handle exit status 1
Given an executable named "bin/cli" with:
"""bash
#!/usr/bin/env bash
exit 1
"""
And a file named "features/debug.feature" with:
"""cucumber
Feature: Exit status in debug environment
@debug
Scenario: Run program with debug code
When I run `cli`
Then the exit status should be 1
"""
When I successfully run `cucumber`
Then the features should all pass
Scenario: You can use a debug repl in your cli program
If you want to debug a strange error, which only occures in one of your
`cucumber`-tests, the `@debug`-tag becomes handy. You can add `@debug` in
front of your feature/scenario to make `binding.pry` or `byebug` work in
your program.
Please make sure, that there's a statement after the `binding.pry`-call.
Otherwise you might not get an interactive shell, because your program will
just exit.
We are going to demonstrate this using `pry`, but any other interactive
debugger for any other programming language should also work.
Given an executable named "bin/cli" with:
"""ruby
#!/usr/bin/env ruby
$stderr.sync = true
$stdout.sync = true
require 'pry'
binding.pry
exit 0
"""
And a file named "features/debug.feature" with:
"""cucumber
Feature: Exit status in debug environment
@debug
Scenario: Run program with debug code
When I run `cli`
Then the exit status should be 0
"""
When I run `cucumber` interactively
And I stop the command started last if output contains:
"""
pry(main)>
"""
Then the output should match:
"""
7:\s+binding.pry
"""
|