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

Pairing with Developers
In my experience, one of the best methods for improving code, is for Developers to test their own code before it passed for the official test cycle.

However, the caveat to this is, I have worked closely with developers and through desk demos, “prodding the code” & pairing to look at bugs found, they learn the different approaches we take to testing their code.

Not only am I learning more about what goes on under the hood, but developers are learning more about their approach to testing.

I have had it said more than once, by developers, that through these pairing sessions, I have helped make them become better developers.


Software testing plays a crucial role in enhancing code quality and overall software development. Here are several ways in which software testing contributes to code quality within a working group involving testers and developers:

  1. Bug Identification and Resolution:
  • Testing helps identify and catch bugs and defects in the code before it reaches the production stage.
  • Early bug detection allows for prompt resolution, preventing issues from reaching end-users.
  1. Validation of Requirements:
  • Testing ensures that the code meets the specified requirements and functionalities.
  • It helps bridge the gap between what is expected and what is delivered, improving alignment with user needs.
  1. Improved Code Stability:
  • Thorough testing contributes to code stability by identifying and addressing potential issues related to system crashes or unexpected behavior.
  1. Regression Testing:
  • Regular regression testing ensures that new changes or features do not negatively impact existing functionalities.
  • It helps maintain the integrity of the codebase over time.
  1. Enhanced User Experience:
  • Testing contributes to a positive user experience by identifying and addressing usability issues, ensuring software is user-friendly.
  1. Performance Testing:
  • Testing includes performance evaluation, ensuring that the code performs well under various conditions.
  • This helps in identifying and addressing performance bottlenecks.
  1. Security Testing:
  • Testing helps identify vulnerabilities and security issues in the code, contributing to a more secure application.
  • It is crucial for safeguarding sensitive user data.
  1. Code Documentation:
  • The testing process often involves creating test cases and documentation, which can serve as valuable resources for developers to understand the codebase.
  1. Collaboration and Communication:
  • The collaboration between testers and developers fosters communication and mutual understanding, leading to better code quality.
  • Testers can provide valuable feedback to developers, and vice versa.
  1. Continuous Improvement:
  • A testing mindset promotes a culture of continuous improvement, encouraging developers to write more robust and maintainable code.

In summary, software testing is integral to ensuring code quality by identifying and addressing issues at various stages of the development process. It contributes to the creation of reliable, stable, and user-friendly software products. The collaboration between testers and developers in your working group is a positive step toward achieving these quality goals.

1 Like