You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
I have updated my question to be clearer. Your first point is actually what I want to ask: some people might say testing that the class is calling the other object specific number of times might be going too much into internal implementation details of original class. So how do you differentiate what is implementation details and what is dependency that needs testingPhuong Nguyen– Phuong Nguyen2016-10-18 01:50:53 +00:00Commented Oct 18, 2016 at 1:50
-
2I'd add the case where you want to ensure the tested code can handle cases that are hard or complex to induce without mocking. For example; How does my class handle an out of memory exception thrown by its dependency without actually forcing the dependency to run out of memory?axl– axl2016-10-18 04:58:42 +00:00Commented Oct 18, 2016 at 4:58
-
1@axl Exactly, it's about having 100% control over the dependencies being passed in, and what they're outputting, without having to mess up your tests with setup / configuration / manipulation code required for using concrete instances.Callum Bradbury– Callum Bradbury2016-10-18 09:21:53 +00:00Commented Oct 18, 2016 at 9:21
-
@PhuongNguyen : A unit test is there to ensure the unit of code is behaving the way it is supposed to. The number of calls to another object may be important. For example, you may have built a function that is calling an IO component that you've also built, and you'd like to know that the function does so optimally. Then again, it may not be important to know how often the method calls some transformational helper function. It's a judgement call you have to make on a case by case basis.Matthew Flynn– Matthew Flynn2016-10-18 16:11:38 +00:00Commented Oct 18, 2016 at 16:11
Add a comment
|
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you