Click here to Skip to main content
15,889,808 members

Survey Results

Do you do Unit Testing?

Survey period: 22 Jun 2020 to 29 Jun 2020

We ran this 5 years ago. Let's see if things have changed.

OptionVotes% 
We unit test everywhere, always.9912.36
We test the most important and/or non-trivial units,15619.48
We unit test some pieces. Sometimes.27033.71
We never unit test,20225.22
What is unit testing?789.74



 
GeneralNot working on object oriented software Pin
den2k8824-Jun-20 21:42
professionalden2k8824-Jun-20 21:42 
QuestionRe: Not working on object oriented software Pin
r_hyde25-Jun-20 10:41
r_hyde25-Jun-20 10:41 
GeneralSome pieces, sometimes. Pin
Greg Utas23-Jun-20 14:28
professionalGreg Utas23-Jun-20 14:28 
GeneralTesting... Unit/Integrated/Integration Pin
Julius Adam22-Jun-20 20:59
Julius Adam22-Jun-20 20:59 
GeneralRe: Testing... Unit/Integrated/Integration Pin
Matt McGuire24-Jun-20 7:02
professionalMatt McGuire24-Jun-20 7:02 
GeneralRe: Testing... Unit/Integrated/Integration Pin
Julius Adam24-Jun-20 7:23
Julius Adam24-Jun-20 7:23 
GeneralI didn't vote because... Pin
Dean Roddey22-Jun-20 13:53
Dean Roddey22-Jun-20 13:53 
GeneralIntegration testing rather than unit testing Pin
Marc Clifton22-Jun-20 2:36
mvaMarc Clifton22-Jun-20 2:36 
GeneralRe: Integration testing rather than unit testing Pin
Erik Burd22-Jun-20 7:51
professionalErik Burd22-Jun-20 7:51 
GeneralRe: Integration testing rather than unit testing Pin
Fabio Franco22-Jun-20 23:07
professionalFabio Franco22-Jun-20 23:07 
GeneralI picked "What" Because Pin
W Balboos, GHB22-Jun-20 0:56
W Balboos, GHB22-Jun-20 0:56 
GeneralRe: I picked "What" Because Pin
Sander Rossel22-Jun-20 1:49
professionalSander Rossel22-Jun-20 1:49 
GeneralRe: I picked "What" Because Pin
W Balboos, GHB22-Jun-20 2:03
W Balboos, GHB22-Jun-20 2:03 
GeneralRe: I picked "What" Because Pin
Sander Rossel22-Jun-20 2:37
professionalSander Rossel22-Jun-20 2:37 
GeneralYoUr COde MuSt Be UnIT teStEd... PinPopular
Sander Rossel21-Jun-20 22:41
professionalSander Rossel21-Jun-20 22:41 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
W Balboos, GHB22-Jun-20 1:04
W Balboos, GHB22-Jun-20 1:04 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
Sander Rossel22-Jun-20 1:46
professionalSander Rossel22-Jun-20 1:46 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
W Balboos, GHB22-Jun-20 1:50
W Balboos, GHB22-Jun-20 1:50 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
Sander Rossel22-Jun-20 2:33
professionalSander Rossel22-Jun-20 2:33 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
W Balboos, GHB22-Jun-20 3:00
W Balboos, GHB22-Jun-20 3:00 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
Sander Rossel22-Jun-20 3:22
professionalSander Rossel22-Jun-20 3:22 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
W Balboos, GHB22-Jun-20 3:27
W Balboos, GHB22-Jun-20 3:27 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
Sander Rossel22-Jun-20 3:37
professionalSander Rossel22-Jun-20 3:37 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
W Balboos, GHB22-Jun-20 3:54
W Balboos, GHB22-Jun-20 3:54 
GeneralRe: YoUr COde MuSt Be UnIT teStEd... Pin
Sander Rossel22-Jun-20 4:47
professionalSander Rossel22-Jun-20 4:47 
W∴ Balboos, GHB wrote:
Which simply means Testing. No?
No, it's a very specific form of testing.
A unit test is an automated test that tests a single method.
For example:
C#
public int Add(int a, int b) { return a + b; }
That code is never going to change and it's very simple.
Does it need a unit test? It couldn't hurt, but it probably has little added value.
Valid unit tests would be:
C#
Assert.Equal(Add(1, 1), 2);
Assert.Equal(Add(1, 2), 3);
Assert.Equal(Add(-1, -2), -3);
Assert.Equal(Add(int.MaxValue, 1), heck I don't know, int.MinValue or something);
Now my point is, that last test may or may not be something you'll think about.
If you don't, your software may still overflow despite having the previous two unit tests.
If you do, this is probably a real issue that you've already thought about when creating your Add function and you'll probably have used a long instead.
However, whether or not this code works all depends on whether it's called with such high values.
If you use this function for some invoicing, you really won't hit that overflow, but you can't test that with a unit test.
Another issue with these tests, the first test is prone to errors itself.
If you mess up the Add function and return a + a or b + b (or even 1 + a or b), this test will still pass even though the function broke.
Ultimately, you may replace your Add function with Math.Add and you'll be left with a couple of tests that you need to remove (or rewrite) as well.

So having these unit tests in place is only going to help you on the off chance that someone somehow messes up the Add function.
A smoke, acceptance or regression test will soon find that issue if it's not already caught during code review.
True, you'd much rather find it with an automated unit test, but writing so many unit tests comes at a price.
Don't forget, your tests are just more code and they'll have bugs just like the code you're testing.
It's also more code that you need to maintain, which costs time and time is money.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.