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*
-
7I've never found that argument for testing private methods compelling. You refactor code into methods all the time for reasons that have nothing to do with the public API of a class, and it's a very nice thing to be able to test those methods independently, without involving any other code. That is the reason you refactored, right? To get a piece of independent functionality. That functionality should be testable independently as well.Robert Harvey– Robert Harvey2013-12-12 16:47:01 +00:00Commented Dec 12, 2013 at 16:47
-
1@RobertHarvey answer expanded with a rant addressing this. "Private methods are beneficial to unit testing..."gnat– gnat2013-12-13 07:54:44 +00:00Commented Dec 13, 2013 at 7:54
-
I see what you're saying about private methods and code coverage, but I wasn't really advocating making those methods public so that you can test them. I was advocating having a way to test them independently even though they are private. You can still have your public tests that touch the private method, if you want to. And I can have my private tests.Robert Harvey– Robert Harvey2013-12-13 16:06:10 +00:00Commented Dec 13, 2013 at 16:06
-
@RobertHarvey I see. Guess it boils down to coding style. At the amount of private methods I typically produce, and at the rate I refactor these, having tests for them is simply a luxury I can't afford. Non-private API is another matter, I tend to be quite reluctant and slow at modifying itgnat– gnat2013-12-13 16:14:17 +00:00Commented Dec 13, 2013 at 16:14
-
Perhaps you're better at writing methods that work the first time than I am. For me, I need to test the method to make sure that it works first before I can move on, and having to test it indirectly by firing off a series of other methods would be clumsy and awkward.Robert Harvey– Robert Harvey2013-12-13 16:16:29 +00:00Commented Dec 13, 2013 at 16:16
|
Show 1 more 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
lang-java