SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Why Don't You Unit Test Code?


Why Don't You Unit Test Code?

Author
Message
Steve Jones
Steve Jones
SSC Guru
SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)

Group: Administrators
Points: 247371 Visits: 19791
Comments posted to this topic are about the item Why Don't You Unit Test Code?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Dave Poole
Dave Poole
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26522 Visits: 3541
My experience is that people in IT abdicate their power and authority. Many of the problems faced by IT are as a result of this.

Some of the things for which IT people ask permission are the equivalent of a garage mechanic asking your permission to reconnect the brakes of your car after a service.

Having the time to experiment with and learn new techniques is vitally important. You won't get that if you are always on the back foot and in fire fighting mode. I find that a refusal from management is rarely a hard NO, it is usually couched in terms that can be interpreted as no and usually an IT person will give up at this point.

  • Quantify the problem that NOT having unit tests creates

  • Clarify that the lack of tests will make the situation worse over time

  • Quantify the benefit of having unit tests

  • State the cost in time and money for introducing unit tests

  • Identify the milestones that will demonstrate that the introduction of unit tests has lead to a benefit

  • State the implementation plan



In other words, put together a business plan for the introduction of unit tests. It helps if quantifying the problem of NOT having unit tests clearly places your bosses or your bosses bosses initiatives at risk.
Be honest but not too honest. There was a standing joke that if Atari sold KFC they would sell it as warm dead bird.

LinkedIn Profile
www.simple-talk.com
Dave Poole
Dave Poole
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26522 Visits: 3541
https://martinfowler.com/bliki/TradableQualityHypothesis.html

LinkedIn Profile
www.simple-talk.com
chrisn-585491
chrisn-585491
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5865 Visits: 2645
Sometimes it's the scope of the unit tests. There are some situations with complex UI, business rules and databases where it's difficult to build automated coverage beyond a certain percentage. Or the unit tests approach the complexity of the code under test and require unit tests of their own... It's turtles all the way down.

A recent project I did, spent 85% of the time creating and maintain unit tests, only to have a unique corner case not covered by tests come in from the field and require refactoring of the code and tests.
ZZartin
ZZartin
SSCrazy Eights
SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)

Group: General Forum Members
Points: 9748 Visits: 11927
I really think most people just don't understand what the difference is between a unit test and an end to end test.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)

Group: Administrators
Points: 247371 Visits: 19791
ZZartin - Friday, October 6, 2017 9:38 AM
I really think most people just don't understand what the difference is between a unit test and an end to end test.
I think this is true. They also don't understand how long manual testing can take. Or maybe they just like manual testing better.

I also think there's the issue that writing tests is an art, and trying to write tests that are self-contained and not too brittle takes practice. We also want to make sure we're not testing trivial items.

This isn't easy. I was hoping to have more responses.


Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)

Group: General Forum Members
Points: 377032 Visits: 42913
David.Poole - Friday, October 6, 2017 2:07 AM
My experience is that people in IT abdicate their power and authority. Many of the problems faced by IT are as a result of this.

Some of the things for which IT people ask permission are the equivalent of a garage mechanic asking your permission to reconnect the brakes of your car after a service.

Having the time to experiment with and learn new techniques is vitally important. You won't get that if you are always on the back foot and in fire fighting mode. I find that a refusal from management is rarely a hard NO, it is usually couched in terms that can be interpreted as no and usually an IT person will give up at this point.

  • Quantify the problem that NOT having unit tests creates

  • Clarify that the lack of tests will make the situation worse over time

  • Quantify the benefit of having unit tests

  • State the cost in time and money for introducing unit tests

  • Identify the milestones that will demonstrate that the introduction of unit tests has lead to a benefit

  • State the implementation plan



In other words, put together a business plan for the introduction of unit tests. It helps if quantifying the problem of NOT having unit tests clearly places your bosses or your bosses bosses initiatives at risk.
Be honest but not too honest. There was a standing joke that if Atari sold KFC they would sell it as warm dead bird.


As a part of this, someone should also "State the cost in time and money for NOT doing Unit Tests". It's a whole lot more substantial than most would think.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Robert Sterbal-482516
Robert Sterbal-482516
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1037 Visits: 304
I'd be interested in the calculated number of test are after a thousand lines of code. I'm guess that is a big number.
Dave Poole
Dave Poole
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26522 Visits: 3541
Robert Sterbal-482516 - Saturday, October 7, 2017 3:07 PM
I'd be interested in the calculated number of test are after a thousand lines of code. I'm guess that is a big number.

In my experience it lines of code to number of tests isn't an easily correlated thing. To give an example I built an ETL tool using Apache Spark and one of my team had invented a great way of testing it. We had our business analysts and testers capture the different input data sets and expected outputs in Git markdown tables held as files in the project. The project structure for where the markdown files resided mirrored the project structure of the ETL components. This meant that a few simple tests could test a huge number of transforms and scenarios.
Similarly the PyTest framework allows metadata to be supplied so again, one test run multiple times for different scenarios.
The need to test and to do so efficiently was a considerable factor in the design of the solution. The result is an ETL framework that we can extend amd refactor with confidence and with greater speed than we ever imagined. So much so that the biggest time consumer is now business people deciding what they want and fighting about priorities


LinkedIn Profile
www.simple-talk.com
jhgoodwin
jhgoodwin
SSC-Enthusiastic
SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)

Group: General Forum Members
Points: 185 Visits: 85
David.Poole - Friday, October 6, 2017 2:07 AM
My experience is that people in IT abdicate their power and authority. Many of the problems faced by IT are as a result of this.
...

David has some great points.
I have seen coworkers approach testing and quality with a defeatism that is frankly unthinkable. If something is unacceptable, why do it?

With regards to E2E/integration tests vs unit tests, I have to push against this almost daily. Getting people to write *REAL* unit tests takes effort in challenging people to decompose problems into the small assumptions they make in operating systems.

The only valid reason I could see not to write unit tests would be that you expect to abandon your work, immediately.

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search