| 1 |
@logging |
| 2 |
@no_capture |
| 3 |
Feature: No-logcapture mode (normal mode) shows log-records |
| 4 |
|
| 5 |
As a tester |
| 6 |
I want that sometimes that log output is not captured |
| 7 |
So that I can see progress even in case of success (or failures) |
| 8 |
|
| 9 |
|
| 10 |
@setup |
| 11 |
Scenario: Feature Setup |
| 12 |
Given a new working directory |
| 13 |
And a file named "features/steps/use_behave4cmd_steps.py" with: |
| 14 |
""" |
| 15 |
import behave4cmd0.log.steps |
| 16 |
import behave4cmd0.failing_steps |
| 17 |
import behave4cmd0.passing_steps |
| 18 |
""" |
| 19 |
|
| 20 |
|
| 21 |
Scenario: Log records are shown when scenario passes (CASE 1) |
| 22 |
|
| 23 |
Ensure that log-records are filtered out if log_record.level is too low. |
| 24 |
|
| 25 |
Given a file named "features/environment.py" with: |
| 26 |
""" |
| 27 |
def before_all(context): |
| 28 |
import logging |
| 29 |
context.config.setup_logging(logging.WARN) |
| 30 |
# -- SAME AS: |
| 31 |
# logging.basicConfig() |
| 32 |
# logging.getLogger().setLevel(logging.WARN) |
| 33 |
""" |
| 34 |
And a file named "features/logging.passing_example.feature" with: |
| 35 |
""" |
| 36 |
Feature: |
| 37 |
Scenario: Passing |
| 38 |
Given I create log records with: |
| 39 |
| category | level | message | |
| 40 |
| root | ERROR | Hello Alice | |
| 41 |
| root | WARN | Hello Bob | |
| 42 |
| root | INFO | Hello Charly | |
| 43 |
| root | DEBUG | Hello Doro | |
| 44 |
When another step passes |
| 45 |
""" |
| 46 |
When I run "behave -f plain -T --no-logcapture features/logging.passing_example.feature" |
| 47 |
Then it should pass |
| 48 |
And the command output should contain the following log records: |
| 49 |
| category | level | message | |
| 50 |
| root | ERROR | Hello Alice | |
| 51 |
| root | WARN | Hello Bob | |
| 52 |
But the command output should not contain the following log records: |
| 53 |
| category | level | message | Comment | |
| 54 |
| root | INFO | Hello Charly | Filtered-out | |
| 55 |
| root | DEBUG | Hello Doro | Filtered-out | |
| 56 |
And note that "log_records with level below WARN are filtered out" |
| 57 |
|
| 58 |
|
| 59 |
@no_capture |
| 60 |
Scenario: Log records are shown up to first failing step (CASE 2) |
| 61 |
|
| 62 |
Ensure that log-records are filtered out if log_record.level is too low. |
| 63 |
|
| 64 |
Given a file named "features/environment.py" with: |
| 65 |
""" |
| 66 |
def before_all(context): |
| 67 |
context.config.setup_logging() |
| 68 |
""" |
| 69 |
And a file named "features/logging.failing_example.feature" with: |
| 70 |
""" |
| 71 |
Feature: |
| 72 |
Scenario: Failing |
| 73 |
Given I create log records with: |
| 74 |
| category | level | message | |
| 75 |
| root | ERROR | Hello Alice | |
| 76 |
| root | WARN | Hello Bob | |
| 77 |
| root | INFO | Hello Charly | |
| 78 |
| root | DEBUG | Hello Doro | |
| 79 |
When another step fails |
| 80 |
Then I create log records with: |
| 81 |
| category | level | message | |
| 82 |
| root | ERROR | Hello2 Zerberus | |
| 83 |
""" |
| 84 |
When I run "behave -f plain -T --no-logcapture --logging-level=ERROR features/logging.failing_example.feature" |
| 85 |
Then it should fail with: |
| 86 |
""" |
| 87 |
0 scenarios passed, 1 failed, 0 skipped |
| 88 |
1 step passed, 1 failed, 1 skipped, 0 undefined |
| 89 |
""" |
| 90 |
And the command output should contain the following log records: |
| 91 |
| category | level | message | |
| 92 |
| root | ERROR | Hello Alice | |
| 93 |
But the command output should not contain the following log records: |
| 94 |
| category | level | message | Comment | |
| 95 |
| root | WARN | Hello Bob | Filtered-out | |
| 96 |
| root | INFO | Hello Charly | Filtered-out | |
| 97 |
| root | DEBUG | Hello Doro | Filtered-out | |
| 98 |
| root | ERROR | Hello2 Zerberus | Skipped | |
| 99 |
And note that "log_records with level below ERROR are filtered out" |