Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: MockedConstruction needs a setInitializer method #3306

Open
joegottman1 opened this issue Mar 26, 2024 · 0 comments
Open

Feature Request: MockedConstruction needs a setInitializer method #3306

joegottman1 opened this issue Mar 26, 2024 · 0 comments

Comments

@joegottman1
Copy link

While it is possible to set a MockedConstruction's behavior at creation by passing an Initializer parameter as the second parameter to
mockConstruction method, it is not possible to set the Initializer after creation. This is annoying for several reasons:

  1. It doesn't work well with annotating the MockedConstruction with @mock
  2. It doesn't work with the common coding pattern of setting the default behavior of a mock in the setup() method and overriding it if necessary in individual tests.
  3. It makes it impossible to set up a MockedConstruction so that the second mocked T created has different behavior than the first.

Since a MockedConstructor must contain an Initializer for the static function to work, it should be possible to add a method to set this after construction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant