Skip to content
New issue

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

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

Already on GitHub? # to your account

Document how to mock a class, an instance, a method in a class #5638

Closed
4 of 8 tasks
weedySeaDragon opened this issue Apr 29, 2024 · 2 comments · Fixed by #6615
Closed
4 of 8 tasks

Document how to mock a class, an instance, a method in a class #5638

weedySeaDragon opened this issue Apr 29, 2024 · 2 comments · Fixed by #6615
Labels
documentation Improvements or additions to documentation pr welcome

Comments

@weedySeaDragon
Copy link
Contributor

weedySeaDragon commented Apr 29, 2024

Clear and concise description of the problem

The documentation explains how to mock modules, functions, etc., but never explains how to mock classes and their related entities. There are many approaches out on the web; a developer has to wade through different approaches and test each of them to determine if they are correct or not.

Suggested solution

The documentation should have verified explanations and examples for mocking:

  • an entire class
  • an instance of a class
  • a single method from a class
  • other related entities that should also be included

This will likely mean some extended discussions in order to agree on correct approaches. (And perhaps only one of many valid approaches is shown, with pointers or a brief explanation for others.)
Discussion(s) could take place in.... the discussions .

Related: #4001 Utility to auto mock class instance

I'm quite interested in this and can will kick-off a discussion.

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

Doesn't "Mock exported class implementation" on the same page you listed already cover it?

@weedySeaDragon
Copy link
Contributor Author

I'm proposing that the documentation be updated to include examples of how to mock not just an instance of a class, but a single method, or a static method, or all instances of a class, etc., to cover all of the OO/class things can be mocked.

(And sorry for the delay in responding. I appreciate that you responded quickly. :-) )

@sheremet-va sheremet-va added documentation Improvements or additions to documentation pr welcome and removed enhancement: pending triage labels May 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
documentation Improvements or additions to documentation pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants