
Testing is not for beginners
- Transfer
I am a big fan of testing. I write about it in my blog and mailing list, I discuss it with other developers in my free time, I went so far as to even create a training course on testing in Go.
But despite all my love of testing, I do not recommend it to beginners.
Sounds wild, right? In this article I am going to clarify my point of view in more detail, but the whole point, in the end, comes down to two points:
I understand that this is, in principle, one point. In any case, I broke it into two in order to make it easier to understand.
I know that many of you will disagree with me, but please read the article, and if after reading you remain unconvinced, I will be happy to discuss this with you. In the end, I'm here to study
Whenever a newbie writes code, its main purpose is not to decompose tasks, avoid global variables, or write test code. Honestly, most beginners probably have little idea what it all is. In fact, their main goal is simple - to make this damn thing work. Everything.
Confirming this is unlikely to require any effort, just look at the code written by the newbie.
Go web application? Surely they write SQL queries everywhere and everywhere in the code, and the connection to the database is almost guaranteed to be stored in a global variable.
Rails application? Surely you will see the business logic in the views and tons of logic jams in the controllers.
PHP web application? I won’t be surprised if ALL the logic is in one single php file - form parsing, interaction with the database, etc.
Even if we take something elementary, say, a calculator with limited functionality, we will still come across examples like the ones described by me . This is not at all due to the fact that beginners do not care, they just do not yet know how to do better.
Beginners don’t know what dependency injection is, they don’t understand how global variables complicate testing, most likely they don’t know what mock is, so it's pretty ridiculous to expect them to understand how to design code that is easy to code.
As a result, for a beginner, only the simplest tests like these make sense:
Although I have no problem showing this to beginners and giving them an idea of what testing is, I think it's pretty ridiculous to show them this code and pretend that it is something like a real test.
In the end, this leads to the fact that we begin to teach them more. We are trying to explain what dependency injection is, why global variables complicate testing, like time.Now () can make it difficult to check border cases. And in this place I start to worry, because we no longer teach the beginner how to write code. At this moment, we teach him how to write code AND HOW TO TEST at the same time. And that brings me to the second point ...
As before, I want you to think about the code written by the newbie, but this time I want you to remember some of the first programs you wrote.
If you were like me, your first web application might look something like this:
A work of art, right?
Now imagine that you just wrote this code for the first time and someone tells you that you should test it. And you have to use React. And the framework. Oh, and it wouldn't hurt you to tweak the database, and possibly GraphQL to work with it.
I don’t know why, but we developers have a habit of using the skills gained over many years of experience and practice and expecting others, especially beginners, to do the same . This is just ridiculous! This is to be expected from someone that he will understand mathematics only because you yourself have already studied trigonometry, algebra and much more, and you can use mathematics to solve specific problems.
If something works well for you, it does not mean that it will suit beginners. They can be out of context, without the experience and practice necessary to benefit from what you use. Or perhaps the problems they are struggling with are actually too simple to use all these complex solutions.
It’s as if we forgot how we studied step by step how HTTP requests work. How headers work. Cookies Forms. How does a POST request to the server work - or even that there are EXTRA HTTP methods in general. And we learned all of this with the good old trial and error method.
Actually, I don’t think that the tests are to blame, the real problem is that we firmly believe that you should learn programming, testing, website building and a million other things at the same time. I don’t really know how this happened, but, I suspect, part of the problem is that we do not bother to think about what it will cost to study all of this. A beginner asks “what should I learn?” And we start “learn testing, react, graphql and go, but use only the standard library ...”
No, no, and again no. Just stop.

This is ridiculous, since in other conditions the absurdity of such an approach is obvious. If you want to teach someone how to play football, you’ll start with the basics like packing and dribbling. You won’t start by saying “This is how professionals do it,” turn on the video from Ronaldo and leave. So what the hell are we doing with newcomers to programming?
We try to justify ourselves by saying, “Well, of course they understand that it is impossible to learn all this at the same time,” but they do not understand! The situation is aggravated by the fact that novice developers, falling into this trap, feel like crap due to being stuck. It seems to them that they simply don’t have what it takes to become a developer and it’s a shame for you and me, because many of them would love programming if they didn’t crash into this brick wall.
And this leads me to what I actually wanted to say - many of us study better if we focus on studying several things at once. We want new challenges, we want to try new things, but we do not want to get confused and fall into a stupor. Learning about testing and anything else - for example, how to create a web application, how http, cookie, etc. works - is an easy way to fall into this trap. And as a result, I usually recommend that you study the rest first, and testing last. You can always go back to your old projects and see how you would rebuild them now when you studied testing, but this is possible only if you are not overloaded, upset and, in the end, have not abandoned this business.
Cool forward! Of course, you can first study testing, and only then web development or some other topic. I’m sure some did just that and you might like this way more. When I say that testing is not for beginners, I do not say that this is a bad topic to study, I mean that trying to learn testing plus anything else is a mistake.
Most people want to learn how to create web applications or something visual first, but this does not mean that you need to start with this, you can very well start with testing. You probably won’t begin to understand anything until you get the bumps, but don’t let me stop you from learning what you want.
It also does not mean that you cannot study during pair programming or something like that. With a mentor, you can learn many things at the same time and successfully withstand this load, because you have someone who will guide you through all this. In this situation, if you get lost, you will not get into a dead end and you will not feel like a failure, because there will be someone who says “You are doing fine, it's just too difficult for now. Next time try X and Y instead! ” Simply put, in this scenario, you will not be confused, disappointed and quit.
But despite all my love of testing, I do not recommend it to beginners.
Sounds wild, right? In this article I am going to clarify my point of view in more detail, but the whole point, in the end, comes down to two points:
- Beginners do not have enough knowledge to write anything other than the simplest tests. This inevitably leads to the next point ...
- Trying to train the skills necessary to write realistic tests while learning programming is extremely difficult
I understand that this is, in principle, one point. In any case, I broke it into two in order to make it easier to understand.
I know that many of you will disagree with me, but please read the article, and if after reading you remain unconvinced, I will be happy to discuss this with you. In the end, I'm here to study
Beginners lack knowledge to write anything other than the simplest tests
Whenever a newbie writes code, its main purpose is not to decompose tasks, avoid global variables, or write test code. Honestly, most beginners probably have little idea what it all is. In fact, their main goal is simple - to make this damn thing work. Everything.
Confirming this is unlikely to require any effort, just look at the code written by the newbie.
Go web application? Surely they write SQL queries everywhere and everywhere in the code, and the connection to the database is almost guaranteed to be stored in a global variable.
Rails application? Surely you will see the business logic in the views and tons of logic jams in the controllers.
PHP web application? I won’t be surprised if ALL the logic is in one single php file - form parsing, interaction with the database, etc.
Even if we take something elementary, say, a calculator with limited functionality, we will still come across examples like the ones described by me . This is not at all due to the fact that beginners do not care, they just do not yet know how to do better.
Beginners don’t know what dependency injection is, they don’t understand how global variables complicate testing, most likely they don’t know what mock is, so it's pretty ridiculous to expect them to understand how to design code that is easy to code.
As a result, for a beginner, only the simplest tests like these make sense:
func Add(a, b int) int {
return a+b
}
// And a test...
func TestAdd(t *testing.T) {
got := Add(2, 4)
want := 6
if got != want {
t.Errorf("Add() = %d; want %d", got, want)
}
}
Although I have no problem showing this to beginners and giving them an idea of what testing is, I think it's pretty ridiculous to show them this code and pretend that it is something like a real test.
In the end, this leads to the fact that we begin to teach them more. We are trying to explain what dependency injection is, why global variables complicate testing, like time.Now () can make it difficult to check border cases. And in this place I start to worry, because we no longer teach the beginner how to write code. At this moment, we teach him how to write code AND HOW TO TEST at the same time. And that brings me to the second point ...
Trying to train the skills necessary to write realistic tests while learning programming is extremely difficult
As before, I want you to think about the code written by the newbie, but this time I want you to remember some of the first programs you wrote.
If you were like me, your first web application might look something like this:
A work of art, right?
Now imagine that you just wrote this code for the first time and someone tells you that you should test it. And you have to use React. And the framework. Oh, and it wouldn't hurt you to tweak the database, and possibly GraphQL to work with it.
I don’t know why, but we developers have a habit of using the skills gained over many years of experience and practice and expecting others, especially beginners, to do the same . This is just ridiculous! This is to be expected from someone that he will understand mathematics only because you yourself have already studied trigonometry, algebra and much more, and you can use mathematics to solve specific problems.
If something works well for you, it does not mean that it will suit beginners. They can be out of context, without the experience and practice necessary to benefit from what you use. Or perhaps the problems they are struggling with are actually too simple to use all these complex solutions.
It’s as if we forgot how we studied step by step how HTTP requests work. How headers work. Cookies Forms. How does a POST request to the server work - or even that there are EXTRA HTTP methods in general. And we learned all of this with the good old trial and error method.
Actually, I don’t think that the tests are to blame, the real problem is that we firmly believe that you should learn programming, testing, website building and a million other things at the same time. I don’t really know how this happened, but, I suspect, part of the problem is that we do not bother to think about what it will cost to study all of this. A beginner asks “what should I learn?” And we start “learn testing, react, graphql and go, but use only the standard library ...”
No, no, and again no. Just stop.

This is ridiculous, since in other conditions the absurdity of such an approach is obvious. If you want to teach someone how to play football, you’ll start with the basics like packing and dribbling. You won’t start by saying “This is how professionals do it,” turn on the video from Ronaldo and leave. So what the hell are we doing with newcomers to programming?
We try to justify ourselves by saying, “Well, of course they understand that it is impossible to learn all this at the same time,” but they do not understand! The situation is aggravated by the fact that novice developers, falling into this trap, feel like crap due to being stuck. It seems to them that they simply don’t have what it takes to become a developer and it’s a shame for you and me, because many of them would love programming if they didn’t crash into this brick wall.
And this leads me to what I actually wanted to say - many of us study better if we focus on studying several things at once. We want new challenges, we want to try new things, but we do not want to get confused and fall into a stupor. Learning about testing and anything else - for example, how to create a web application, how http, cookie, etc. works - is an easy way to fall into this trap. And as a result, I usually recommend that you study the rest first, and testing last. You can always go back to your old projects and see how you would rebuild them now when you studied testing, but this is possible only if you are not overloaded, upset and, in the end, have not abandoned this business.
But what if I want to learn how to test ?! (and a million others “what if”)
Cool forward! Of course, you can first study testing, and only then web development or some other topic. I’m sure some did just that and you might like this way more. When I say that testing is not for beginners, I do not say that this is a bad topic to study, I mean that trying to learn testing plus anything else is a mistake.
Most people want to learn how to create web applications or something visual first, but this does not mean that you need to start with this, you can very well start with testing. You probably won’t begin to understand anything until you get the bumps, but don’t let me stop you from learning what you want.
It also does not mean that you cannot study during pair programming or something like that. With a mentor, you can learn many things at the same time and successfully withstand this load, because you have someone who will guide you through all this. In this situation, if you get lost, you will not get into a dead end and you will not feel like a failure, because there will be someone who says “You are doing fine, it's just too difficult for now. Next time try X and Y instead! ” Simply put, in this scenario, you will not be confused, disappointed and quit.