Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Check out this session of the Testμ Conference as Gil Zilberfeld talks about concrete examples of anti-patterns in tests and how to clean them.

TestMu AI
January 11, 2026
Writing dirty tests is similar to having no tests. The tests must change as the production code evolves. The dirtier the test, the more challenging it is to change them. Therefore, it’s vital to write clean tests and code.
However, it looks like the test code is not considered the ‘real code’ and so is not labeled ‘dirty tests’.
In this session of the Testμ Conference, Gil Zilberfeld, CTA & CEO at TestinGil, collaborated with Anmol Gupta – Senior Product Manager at TestMu AI, to talk about concrete examples of anti-patterns in tests and how to clean them.
Below are the key takeaways from the session.
Let’s explore more in this session!
Gil starts the session by explaining test and production code are the same thing and that we should apply the same standards to them. But it seems like we won’t do that!
He provides a few different reasons why writing clean tests and code is crucial.
We know the real code, but it’s not like real code as it goes into production and is used by real users. We don’t consider ourselves real users, although we know we will be the users of this code.

There’s an evolution of code in which tests can be different because when we write a test that passes, it goes back in our mind to somewhere else, and we probably think we’ll never see that one again. We know we will, but we are focusing on the next test and forgot about the one that already passed.
It’s our perception of the differences between the code and how real it is. Access, like whether we go back to test, and if you think about it, we go back to production code. Test code mostly passes unless they’re broken or fragile, regardless of how you want to talk about them. We usually don’t go back until they break. Again we do some kind of separation between the two types of code, like action code.
Ultimately, we need to think about these things differently, and unless we do these same things, we can apply different standards.
According to Gil, we want our code that works over and over again regardless of your method of development, whether agile or waterfall.
As developers, we like to work on new stuff but going back to something that worked before but now doesn’t work is a kind of a backward step. Keeping code clean allows us to create new stuff repeatedly and reduces the time spent on the old stuff. If we could read the code, we would spend less time on it and then move back to the new stuff.
So keeping code clean and tests is like respecting the time of future me or you. We can translate that into readability, maintainability, or anything but going back to the goal of working code over and over and over again translates to how much time and effort we put in and invest now to free some time in the future.
He then describes what good vs. bad code looks like.
Both good and bad codes are different as most of the code reviews are done not in the same room but through pull requests which is not a thing. When we review code, we see it from a different angle because the person who wrote it created the most magnificent code you ever created; otherwise, you wouldn’t say that it’s done. If I write and review the code, it’s excellent to ship it to let other people view it and share their feedback.
He then lists a few famous quotes about clean code.

Gil shares some aspects that make the tests clean. These are as follows.

Gil then went to explain code smells. When you’ve done a lot of coding, there are code smells. These are not problems functionally, but they will create hurdles for you as you proceed later.
There are a few patterns that have a name and usually apply for clean code or unclean code.

He then demonstrates a dirty test example of the controller of a calculator in Java language and how to make it clean utilizing a unit test framework.
In a nutshell, a great test doesn’t have any dissimilarity or difference in the standards between the test code and production code. – he added.
So the first thing is to be nice and the second thing is to think about whether it is important, so everybody can learn how to do it not because of how you would write it as when you do this kind of distinction, people start thinking about if they can still read it that’s not a big problem. Therefore, if you keep these things in mind, everybody can read the important and unimportant stuff.
After the successful Testμ Conference 2022, where thousands of testers, QA professionals, and developers worldwide joined together to discuss on future of testing.
Join the testing revolution at TestMu AI Testμ Conference 2023. Register now!” – The testing revolution is happening, and you don’t want to be left behind. Join us at TestMu AI Testμ Conference 2023 and learn how to stay ahead of the curve. Register now and be a part of the revolution.

Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance