Note that there are some explanatory texts on larger screens.

plurals
  1. POAre unit tests useful for real?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/67299/is-unit-testing-worth-the-effort">Is Unit Testing worth the effort?</a> </p> </blockquote> <p>I know what is the purpose of unit tests generally speaking, but I found some things that bother me.</p> <p>1) Purpose of tests early bug discovery. So, in some of later iterations, if I make some changes in code, automated test have to alarm me and tell me that I've screwed up some long ago forgotten piece of my software.</p> <p>But, say that I have class A and say that is interact with some others class' instance, call it class B.</p> <p>When one writes unit test for class A, he has to mock class B. So, in some future, if one makes some changes in class B, and that causes some bugs, they will reflect only in class B's unit test, not in A's ('cause A's test doesn't use real class B, but it's mock with fixed inputs and outputs). So, I can't see how could unit test do early notifying of made bugs that one isn't aware of? I'm aware of possible bugs in class that I'm changing, I do not need unit test for it, I need test to alarm me of consequences of my changes that makes bug in some "forgotten" class, and that isn't possible with unit tests. Or am I wrong?</p> <p>2) When writing mocks and right expectations of calling methods, their inputs and returning values, one has to know how class-under-test is going to be implemented. And I think that that contradicts with test driven development. In TDD one writes tests first, and, driven by them, one writes a code. But I can't write right expectations (and tests in general) unless I write code that has to be tested. That contradicts with TDD, right?</p> <p>Both of those problems could be solved if I used real objects instead of mocks. But that isn't unit testing then, right? In unit test class-under-test has to be isolated form the rest of the system, not using real classes but mocks.</p> <p>I'm sure that I'm wrong somewhere, but I cannot find where. I've been reading and reading and I can't find what have I understood wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload