ScreenPyHQ / screenpy

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

Make the `Narrator` a singleton. #54

Closed perrygoy closed 1 year ago

perrygoy commented 1 year ago

When we originally created the Narrator class, we kind of thought that it might be useful to create multiple narrators if you needed to log to multiple places. Later we developed the Adapter system and it's super freakin' cool, but also kind of negates the need to have multiple Narrators.

With @bandophahita's work on allowing almost everything to be importable directly from screenpy, i had a concern that folks might accidentally import Narrator when they should be importing the_narrator. Making Narrator a singleton will solve that problem!

perrygoy commented 1 year ago

@bandophahita brought up a good point that maybe it would be useful for someone to be able to have different logs for different extensions, like logging ScreenPy Requests output to a separate file/adapter than ScreenPy Selenium. We currently have pacing kind of assuming there's only one Narrator, though, so we'd need to do some decoupling work and some other changes to make that happen correctly.

For now, we think making Narrator a singleton to address the confusion is a good step, and we'll revisit this if we find a solid use case that we can build towards.

perrygoy commented 1 year ago

After some discussion, we decided not to go with this approach.

It's a little bit surprising, and we have no reason to believe there are folks out there instantiating their own Narrators using the class directly. Instead, we'll push the_narrator as the thing to interact with.