Verifying the behavior of a software system against the expected behavior of that system.
Questions tagged [testing]
1454 questions
282
votes
22 answers
Leaving intentional bugs in code for testers to find
We don't do this at our firm, but one of my friends says that his project manager asked every developer to add intentional bugs just before the product goes to QA. This is how it works:
Just before the product goes to QA, the development team adds…

Krishnabhadra
- 2,440
- 2
- 15
- 14
237
votes
9 answers
Is it normal to spend as much, if not more, time writing tests than actual code?
I find tests a lot trickier and harder to write than the actual code they are testing. It's not unusual for me to spend more time writing the test than the code it is testing.
Is that normal or am I doing something wrong?
The questions “Is unit…

springloaded
- 2,123
- 3
- 11
- 10
171
votes
11 answers
How should I test randomness?
Consider a method to randomly shuffle elements in an array. How would you write a simple yet robust unit test to make sure that this is working?
I've come up with two ideas, both of which have noticeable flaws:
Shuffle the array, then make sure its…

dlras2
- 2,290
- 2
- 17
- 16
151
votes
5 answers
What are the key points of Working Effectively with Legacy Code?
I've seen the book Working Effectively with Legacy Code recommended a few times. What are the key points of this book?
Is there much more to dealing with legacy code than adding unit/integration tests and then refactoring?

Armand
- 6,508
- 4
- 37
- 53
143
votes
7 answers
What is an integration test exactly?
My friends and I have been struggling to classify exactly what is an integration test.
Now, on my way home, I just realised, that every time I try to give a real world example of an integration test, it turns out to be an acceptance test, ie.…

Martin Blore
- 4,645
- 5
- 29
- 35
143
votes
11 answers
Are (database) integration tests bad?
Some people maintain that integration tests are all kinds of bad and wrong - everything must be unit-tested, which means you have to mock dependencies; an option which, for various reasons, I'm not always fond of.
I find that, in some cases, a…

mindplay.dk
- 1,677
- 2
- 11
- 13
139
votes
7 answers
What should you test with unit tests?
I'm freshly out of college, and starting university somewhere next week. We've seen unit tests, but we kinda not used them much; and everyone talks about them, so I figured maybe I should do some.
The problem is, I don't know what to test. Should I…

zneak
- 2,556
- 2
- 23
- 24
131
votes
13 answers
(Why) is it important that a unit test not test dependencies?
I understand the value of automated testing and use it wherever the problem is well-specified enough that I can come up with good test cases. I've noticed, though, that some people here and on StackOverflow emphasize testing only a unit, not its…

dsimcha
- 17,224
- 9
- 64
- 81
130
votes
45 answers
Does giving a developer a slower development machine result in faster/more efficient code?
Suppose I give my developers a screaming fast machine. WPF-based VS2010 loads very quickly. The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world.
This question has two parts...
1) If I…

makerofthings7
- 6,038
- 4
- 39
- 77
123
votes
16 answers
When is unit testing inappropriate or unnecessary?
It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions work on different kinds of projects from me - they work…

Steve Bennett
- 3,419
- 4
- 20
- 24
120
votes
8 answers
How exactly should unit tests be written without mocking extensively?
As I understand, the point of unit tests is to test units of code in isolation. This means, that:
They should not break by any unrelated code change elsewhere in the codebase.
Only one unit test should break by a bug in the tested unit, as opposed…

Alex Lomia
- 1,301
- 2
- 9
- 9
113
votes
14 answers
Should I avoid private methods if I perform TDD?
I'm just now learning TDD. It's my understanding that private methods are untestable and shouldn't be worried about because the public API will provide enough information for verifying an object's integrity.
I've understood OOP for a while. It's my…

pup
- 1,712
- 2
- 13
- 14
110
votes
12 answers
Is testable code better code?
I'm attempting to get into the habit of writing unit tests regularly with my code, but I've read that first it's important to write testable code.
This question touches on SOLID principles of writing testable code, but I want to know if those design…

WannabeCoder
- 2,794
- 5
- 16
- 19
105
votes
9 answers
What's the point of running unit tests on a CI server?
Why would you run unit tests on a CI server?
Surely, by the time something gets committed to master, a developer has already run all the unit tests before and fixed any errors that might've occurred with their new code. Isn't that the point of unit…

Calin Leafshade
- 1,991
- 2
- 14
- 13
102
votes
10 answers
Where is the line between unit testing application logic and distrusting language constructs?
Consider a function like this:
function savePeople(dataStore, people) {
people.forEach(person => dataStore.savePerson(person));
}
It might be used like this:
myDataStore = new Store('some connection string', 'password');
myPeople = ['Joe',…

Jonah
- 1,436
- 2
- 14
- 18