How does software testing affect code quality?


In my company, we have a working group with a tester (me) and some developers.
The goal of this group is to improve the quality of the code.

I would like to know your opinion on the following question: How does software testing affect code quality?


Its unclear to me what you mean by code quality, its very broad topic with different understandings. Does your group know that on their own?
Maybe you should become clear about that in the first place, before you discuss how testing can help to that.
Quality is a value to person :slight_smile:

Despite this here are 2 simple things I can think of:

  • As business requirements like user stories result in concrete code, also tester can at least read that code and find problems in that.
  • Having test-ability is also a thing of code. Testers can demand where they lack that.

The earlier the testing is done the more effective it can have on the code quality, especially if you are testing the requirements to make sure they make sense - to prevent the wrong thing from being developed in the first place. Collaboration is really important here as you need to work closely with the rest of the team to come up with user stories that are easy to understand and reduce the change of different people understanding the story in different ways.

To be honest, equating quality with testing is very old-school. Having sensible software architecture and keeping the customer’s needs in mind while developing the product will contribute to quality more than finding bugs. Software is becoming increasingly complex as time progress so it shouldn’t be only up to us testers to think about the quality and be responsible for it. Everyone involved should be contributing to quality, in their own way.

1 Like

Ill take this to make my previous point more clear:
IMO code quality does not necessarily relates to product quality. (it CAN influence it)
You can have a good product with bad code and you can have a bad product with good code (not meeting the requirements.

Therefore I ask for the definition of code quality.
IMO testing does not that much to that.
bugs != code quality

Finally code quality is more the developers responsibility, its their craft. You may add to this.

It’s good to hear that there are conversations about quality of the code in your company - this is healthy, but the question “How does software testing affect code quality” like Sebastian says is way too broad.

Since its you (the tester) and the developers, I guess you could start at the bottom of the test pyramid;

Screenshot 2023-01-25 at 10.19.37

Talk about what Unit Tests exist, what coverage there is and work up from there. Hopefully, some Unit Tests already exist, and the developers are open to discussion about Unit Tests. If they don’t exist or won’t create them, you might have an issue progressing with your mission of ‘improving code quality’.

Its a not a common goal for a tester to focus on code quality but its an interesting mission.

I caveat this with a bit of caution though, testers telling developers how to write code is a bit of a fools errand and can in many cases lead to dysfunctional team relationships. I recommend being a contributor and tester of ideas but I would not take the lead on driving code quality.

I’d first clarify that mission. To be clear you are not talking about product quality but purely code quality is that correct?

How have you currently judged that your current levels of code quality need improving? What problems are occurring due to the poor code quality.

Can testing help solve those problems I guess is what you are asking?

Try and define what code quality means, could be things like is it readable, understandable, testable, optimal, extendable. Is it easy for someone else to create automated scripts from.

Consider other options, a decent code review process could go a long way to better code, have coding practices in place so developers code fairly consistently

Unit tests can go someway to evaluating code quality but often they just check what its coded to do.

TDD is a bit different as it has got goals regarding clean optimal code. Write a test, then write the least lines of code to make that test past, review and refactor to get it even more optimal. TDD though is not really about testing at all but in terms of your code quality goals it is actually targeted at code quality.

1 Like

Product testing can also indirectly have a strong influence on code quality. Finding a way for common bugs to feedback into good practices and standards is a good option.

Add a chat to your retro on bugs that could easily be removed by improving coding standards.

Lets say you are finding a lot of accessibility issues, as a group you could research w3c standards and agree to make elements of this standard practice. Code quality over time will improve when it becomes natural for the developers to consider this.

Security issues are another big one where some standard coding practices can make a difference.

Testing here is providing an indirect feedback loop to code quality but find a vehicle to make the good actions and practices apply to future coding and not just addressing the bug raised.

1 Like

For me, the strongest dependency between testing and code quality is that the same things that make code more testable also make code easier to change.
Easy to change is one major attribute of software to stay relevant over the years.

1 Like