What is the one most common mistake you make while writing unit tests? Coupling? Lack of cohesion? Try to test too much functionality at once? Not testing enough functionality?
Post some example code if you have an example of that mistake
What is the one most common mistake you make while writing unit tests? Coupling? Lack of cohesion? Try to test too much functionality at once? Not testing enough functionality?
Post some example code if you have an example of that mistake
Writing tests that are too coupled to the code they are testing. This is especially true where I am relying on semantic coupling and things that I just assume to work for the class.
Relying on some implementation detail which is not part of the tested functionality and that might change later on in the development.
Sometimes these assumptions are just too hard to factor out or too prohibitive to take into consideration and being variable.
Lack of coverage -- I rarely test all the cases I should on my first pass.
Testing too much in one test. My unit tests often take on more of the character of integration tests by not confining themselves to the method under test.
Leaving out some small detail (e.g. a hex to dec function where the unit test didn't have any letters in it...)
Well, I sometimes miss out putting out the [Test] C# attribute, and the test doesn't even get run :)
Testing using just some random values instead of including testing with equivalence partitioning and boundary value analysis.
Forgetting to put in the rounding error allowance in double comparison is probably my biggest and most annoying mistake.
Testing code that is present, rather than code that should be present.
I tend to test code that is present when writing unit tests. That is, I'll write a series of tests that have exceptionally high coverage and test the majority of the code that's present, but misses out on basic error conditions not covered by the code.
Making two integration points tightly coupled by not using a mock object or framework.
Hey, you know what? http://msdn.microsoft.com/en-us/magazine/cc163665.aspx
Not getting the test fixtures neat and tidy enough - so writing the tests is harder than it should be.
Writing tests that are neither unit tests( testing only the specific method) nor acceptance tests( testing from user's perspective).
I find that tests that testing 3-4 layers of code in one test that is not grounded at concepts that biz people understand, usually lead to tests that are a burden to maintain and make people get disappointed and turned off by automated testing.
Unit tests with only partial code coverage.
The tests succeed, so I'm feeling good. Things are working. I move on to something else. Turns out there's an untested corner case.