radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
182 stars 49 forks source link

What does a yellow and green Line mean ? #382

Closed dschiller closed 5 years ago

dschiller commented 5 years ago

I have the following Feature Step:

And Change Column "ID" Position 200 Pixel to "Right"

And the following corresponding step.py:

@step('Change Column {column:QuotedString} Position {pixel:g} Pixel to {direction:QuotedString}')
def stepImpl(step, column, pixel, direction):
    Automation.drag('images/app_column_%s.png'%column.lower(), pixel if direction == 'Right' else -pixel)

And on Executing I get this Yellow and Green Line twice and the Code doesn't execute. What does that mean ?

 1. Feature: Saved Items  # features/oGG/E1161.feature
    Saved Items are not changeable

    1. Scenario: Create saved Item "test"
        1. And Change Column "ID" Position 200 Pixel to "Right"     << Yellow Line, Not executed
        1. And Change Column "ID" Position 200 Pixel to "Right"     << Green Line, Not executed

1 features (1 passed)
1 scenarios (1 passed)
1 steps (1 passed)
Run App Features finished within a moment
timofurrer commented 5 years ago

Steps are printed in yellow when it's currently running and are being rewritten in either red for a failed Step or green for a passed Step. Radish only overwrites so many lines as it's written itself. If your Step prints anything during it's execution this rewriting is messed up. Can you add a --no-line-jump to the radish run and see what's printed?

dschiller commented 5 years ago

Thank's a lot! Now it shows an Error. I rather should throw an Exception. But anyway the Image is still there - wonder how that could happen. In any Case, now I can continue working.

1. Feature: Saved Items  # features/oGG/E1161.feature
    Saved Items are not changeable

    1. Scenario: Create saved Item "test"
        1. And Change Column "ID" Position 200 Pixel to "Right"
ERROR: Image not found on Screen - 'images/app_column_id.png'
        1. And Change Column "ID" Position 200 Pixel to "Right"

1 features (1 passed)
1 scenarios (1 passed)
1 steps (1 passed)
Run App Features finished within a moment

Thank's for fast Response Timo!

dschiller commented 5 years ago

I changed my Code behind and changed a simple print to an Exception raise:

# >> Decorators for pyautogui

def handleError(func):
    def wrapper(*args, **kwargs):
        try:
            func(*args, **kwargs)
            return True
        except TypeError as e:
            if 'object is not subscriptable' in str(e):
                raise Exception('ERROR: Image not found on Screen - \'%s\'' % args[0])
            else:
                print(func.__name__ + '():', e)
    return wrapper

Now the Output is much better and I don't need the --no-line-jump Parameter:

1. Feature: Saved Items  # features/Ogg/E1161.feature
    Saved Items are not changeable

    1. Scenario: Create saved Item "test"
        1. And Change Column "ID" Position 200 Pixel to "Right"
              Exception: ERROR: Image not found on Screen - 'images/app_column_id.png'

1 features (0 passed, 1 failed)
1 scenarios (0 passed, 1 failed)
1 steps (0 passed, 1 failed)
Run App Features finished within a moment
timofurrer commented 5 years ago

Awesome! Yeah, you have to raise an Exception for radish to know that the Step failed. I sometimes use prints to debug something and that's where I make the use of --no-line-jump, but never in production.