Contents

Announce information during cucumber run

In order to make debugging easier As a developer using Cucumber I want to have certain information announced

Background:

  • Given I use a fixture named "cli-app"

Scenario: Announce change of directory

  • Given a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-directory
      Scenario: Run command
        Given a directory named "dir.d"
        When I cd to "dir.d"
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    $ cd /
  • And the output should match:
    text
    tmp\/aruba-[^\/]+\/dir.d

Scenario: Announce stdout

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-stdout
      Scenario: Run command
        When I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    <<-STDOUT
    Hello World
    
    STDOUT

Scenario: Announce stderr

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World' >&2
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-stderr
      Scenario: Run command
        When I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    <<-STDERR
    Hello World
    
    STDERR

Scenario: Announce both stderr and stdout

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello' >&2
    echo 'World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-output
      Scenario: Run command
        When I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    <<-STDERR
    Hello
    
    STDERR
  • And the output should contain:
    text
    <<-STDOUT
    World
    
    STDOUT

Scenario: Announce command

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-command
      Scenario: Run command
        When I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    $ aruba-test-cli

Scenario: Announce change of environment variable

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-changed-environment
      Scenario: Run command
        When I set the environment variables to:
          | variable | value    |
          | MY_VAR   | my_value |
        And I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    $ export MY_VAR=my_value

Scenario: Announce change of environment variable which contains special characters

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-changed-environment
      Scenario: Run command
        When I set the environment variables to:
          | variable | value      |
          | MY_VAR   | my value ! |
        And I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    $ export MY_VAR=my\ value\ \

Scenario: Announce file system status of command

This will output information like owner, group, atime, mtime, ctime, size, mode and if command is executable.

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-command-filesystem-status
      Scenario: Run command
        And I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    # mode       => 755
  • And the output should contain:
    text
    # owner
  • And the output should contain:
    text
    # group
  • And the output should contain:
    text
    # ctime
  • And the output should contain:
    text
    # mtime
  • And the output should contain:
    text
    # atime
  • And the output should contain:
    text
    # size
  • And the output should contain:
    text
    # executable

Scenario: Announce content of command

This will output the content of the executable command. This hook should be used with scripts only. For binary executables, to prevent large garbage output, a short replacement message is displayed.

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce-command-content
      Scenario: Run command
        And I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    #!/usr/bin/env bash
    
    echo 'Hello World'

Scenario: Announce everything

  • Given an executable named "bin/aruba-test-cli" with:
    bash
    #!/usr/bin/env bash
    
    echo 'Hello World'
  • And a file named "features/exit_status.feature" with:
    cucumber
    Feature: Announce
      @announce
      Scenario: Run command
        When I run `aruba-test-cli`
        Then the exit status should be 0
  • When I run `cucumber`
  • Then the features should all pass
  • And the output should contain:
    text
    <<-STDOUT
    Hello World
    
    STDOUT
  • And the output should contain:
    text
    <<-STDERR
    
    STDERR
  • And the output should contain:
    text
    <<-COMMAND
    #!/usr/bin/env bash
    
    echo 'Hello World'
    COMMAND
  • And the output should contain:
    text
    <<-COMMAND FILESYSTEM STATUS

Source: features/03_testing_frameworks/cucumber/announce_information_for_troubleshooting.feature at commit c39310a7, Aruba (MIT license).