
On the Relation Between Unit Testing and Code Quality - bsdz
https://arxiv.org/abs/1904.04748
======
pattusk
> The sample consisted of data from both Brazilian and Swedish companies,
> comprising IT departments at one large online media and social networking
> company with around 5,000 employees, one smaller software life-cycle
> consultancy company with around 35 employees, and one company that offers
> programming courses to individuals and companies (around 100 employees), one
> multinational networking and telecommunications equipment and services
> company (with around 115,000 employees), an aerospace and defence company
> (with around 14,000 employees), and an automotive parts manufacturing
> company (with around 160,000 employees).

I may have read the article wrong, but it seems they are evaluating the impact
of unit testing on code quality at fairly well-established companies where
unit testing is already part of the workflow (along with versioning, bug
tracking, etc...)

To me, this seems like it would introduce a strong bias: these companies are
more likely to employ experienced and highly skilled developers than non-IT
shops. What I would be interested in seeing is the effect of introducing unit
testing in a team that does not currently use it.

I remember that as a junior dev, starting to practice unit testing was
incredibly profitable in terms of discipline and code clarity/quality. Of
course now, I can certainly write reliable and clear code without unit tests.
But I don't think I would be able to do so as effectively and quickly had I
not been unit testing my code for most of my career.

I don't think companies that do not practice unit testing are a minority, even
nowadays. As a consultant I've worked for Fortune 500 companies (non IT, but
finance, banking, entertainment...) that did not even have a git nor a bug
tracker and where most of the team had never heard of testing. I've also found
this to be more common than I would have expected among data science teams. To
me these are the shops that would benefit the most from switching to a TDD
approach, and this is where the measurement should happen. Not at a "social
networking company with around 5,000 employees" where everybody has been
practicing it for years...

------
bsdz
Interesting that the authors concluded there's no strong causal relationship
between unit test coverage and the number of defects or perceived code
quality.

I felt that perhaps defects detected by tests during original coverage might
have been overlooked. It seems they were examining the defects detected by
only increasing coverage.

Maybe some of the code coverage they studied were simple smoke tests without
much granularity.

Code quality perception is probably very subjective.

