ScreenPyHQ / screenpy

Screenplay pattern base for Python automated UI test suites.
MIT License
27 stars 3 forks source link

See should have option to bypass get_additive_description #66

Open bandophahita opened 1 year ago

bandophahita commented 1 year ago

There are a few times where using the output from get_additive_description doesn't fit. It would be good if See had an option to bypass using get_additive_description when logging

marcel.will(See(SimpleQuestion(), IsEqual(True)).without_additive_description())
# or maybe 
marcel.will(See.without_additive_description(SimpleQuestion(), IsEqual(True)))

the method name should be something far sexier than the above

perrygoy commented 1 year ago

After a quick discussion on Discord, it seems that adding a .describe() method to return what you actually want to log seems to fix the issue. However!

get_additive_description lower-cases the first letter of the string returned by .describe(). Sometimes you might want a capital. How do we handle this?

class SimpleQuestion:
    ...
    def describe() -> str:
        return "SimpleQuestion"
Marcel sees if simpleQuestion is equal to True.
    Marcel examines SimpleQuestion
        => False
    ... hoping it's equal to False.
        => <True>
bandophahita commented 1 year ago

The short answer is See needs to be told how to use the describe() from the question rather than utilize get_additive_description:

actor.will(See(question, resolution).using_describe())

or maybe there could be some way for get_additive_description to know to skip it's extra processing by setting something on the question?

actor.will(See(question.skipping_additive(), resolution))

perrygoy commented 1 year ago

I feel like that's giving too much to the Questions or to See to know how to do; i don't like the bond that creates between them and get_additive_description.

The answer's gotta be within get_additive_description somehow... maybe we ask ChatGPT to make our additive string for us. :P

bandophahita commented 1 year ago

Could get_additive_description determine if the describe was overridden?