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.
- I agree completely with fixing the design of the code but in the less ideal world of developing for a large company with tight timelines it can be hard to make the case for 'paying off' the technical debt incurred by past teams or poor decisions all at once. To your second point much of the mocking isn't just because we want the test to only fail for one reason - it's because the code being executed can't be permitted to execute without also first handling a large number of dependencies created inside that code. Sorry for moving the goal posts on that one.PremiumTier– PremiumTier2013-03-08 19:46:06 +00:00Commented Mar 8, 2013 at 19:46
- If a better design is not realistic I agree with 'Who cares if you're using the other 5 methods?' Verify the method performs the required function, not how it's doing that.Kwebble– Kwebble2013-03-08 23:01:57 +00:00Commented Mar 8, 2013 at 23:01
- @Kwebble - Understood, however the goal of the question was to determine if there was a simple way to verify behavior for a method when you also have to mock out other behaviors called within the method in order to run the test at all. I want to remove the 'how', but I don't know how :)PremiumTier– PremiumTier2013-03-09 00:28:27 +00:00Commented Mar 9, 2013 at 0:28
- There's no magic silver bullet. There's no "simple way" to test poor code. Either the code-under-test needs to be refactored, or the test code, itself, will also be poor. Either the test will be poor because it will be too specific to the internal details, as you have run into, or as btilly suggested, you can run the tests against a working environment, but then the tests will be much slower and more complex. Either way, the tests will be harder to write, harder to maintain, and prone to false-negatives.Steven Doggart– Steven Doggart2013-03-11 13:32:08 +00:00Commented Mar 11, 2013 at 13:32
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
lang-cs