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*
- 2This is sensible - especially regarding the fact that everything depends on many others. A good unit test should test the minimum possible. Anything that is within that minimum possible amount should be tested by a preceeding unit test. If you've completely tested Parser, you can assume that you can safely use Parser to test ParseStatementJon Story– Jon Story2014-12-04 16:25:16 +00:00Commented Dec 4, 2014 at 16:25
- 6The main purity concern (I think) is to avoid writing circular dependencies in your unit tests. If either the parser or the parser tests use the expander, and this expander test relies on the parser working, then you have a difficult-to-manage risk that all you're testing is that the parser and the expander are consistent, whereas what you wanted to do was test that the expander actually does what it's supposed to. But as long as there's no dependency back the other way, using parser in this unit test isn't really any different from using a standard library in a unit test.Steve Jessop– Steve Jessop2014-12-04 18:15:29 +00:00Commented Dec 4, 2014 at 18:15
- @SteveJessop Good point. It's important to use independent components.Jonathan Eunice– Jonathan Eunice2014-12-04 18:33:13 +00:00Commented Dec 4, 2014 at 18:33
- 3Something I've done in cases where the parser itself is an expensive operation (eg reading data out of Excel files via com interop) is to write test generation methods that run the parser and output code to the console recreate the data structure the parser return. I then copy the output from the generator into more conventional unit tests. This allows reducing the cross dependency in that the parser only needs to be working correctly when the tests were created not every time they're run. (Not wasting a few seconds/test to create/destroy Excel processes was a nice bonus.)Dan Is Fiddling By Firelight– Dan Is Fiddling By Firelight2014-12-04 22:18:58 +00:00Commented Dec 4, 2014 at 22:18
- +1 for @DanNeely's approach. We use something similar to store several serialized versions of our data model as test data, so that we can be sure new code can still work with older data.Chris Hayes– Chris Hayes2014-12-05 03:10:48 +00:00Commented Dec 5, 2014 at 3:10
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