About Software Testing: Why even bother

I'm passionate about the world of software development, I never thought that I was going to understand it, but I'm glad that I challenged myself to learn it.
Search for a command to run...

I'm passionate about the world of software development, I never thought that I was going to understand it, but I'm glad that I challenged myself to learn it.
No comments yet. Be the first to comment.
Classes They are the blueprint for its instances (objects that the class produce). JavaScript has had classes since the ES5 language implementations. In there it was introduced to us the native implementations of “classes” was. Typescript extends the...

GitHub Actions is a tool integrated into Github to perform tasks related to the repository given an “event”. I must give credit to this post and its Youtube video because I was of great help in this regard. If you’re in a hurry, here’s the repo conta...

It's a programming paradigm that focuses on the use of functions as a primary building block of software. In JavaScript, functional programming is supported natively, which means that you can use it without any additional libraries or tools. (And all...

YAML YAML is an information transfer language like JSON or XML. And it is used for its simplicity and consistency. File Extention These YAML files end with .yml or .yaml, either of them is correct. Indentation The indentation in YAML is essential, to...

Testing is necessary to ensure that everything works as expected.
And, to be honest, we all kinda do it when we are developing. Or am I the only one who uses a bunch of console.log, print, fmt.Println or anything like that everywhere?
For example, when we are developing an algorithm we create variables containing the inputs of the use cases that we want to make sure they work. It’s very instinctive. What testing propose is to systematize that.
In the process, you will write a little more code, yes, once. But then, what you’ll get in return is the reliability of your code; it will force you to write more modular code and clean architecture; you can refactor knowing that you need to make sure to pass the tests that you already created; and really put your code to the limit trying all kinds of different edge cases, all while ensuring that their processes do not disrupt development.
True, it sounds too good to be true, right? Well, because it is. You see, although I said that we instinctively already do testing, it’s not like learning and using the tools are trivial things. As with any skill it requires time and practice to master it. Writing good tests is a skill all by itself.
And even when you manage to get the hang of testing, making tests takes time and effort and, most important of all, writing tests don’t assure that no bug will be introduced into the code base. I’m afraid that we don’t write tests for our tests so we can’t be 100% sure that every use case was tested.
Sure, there’s the usual: “caching bugs early” and all things I already mentioned. But, from a developer's point of view, it leads to more reliable and modular code and clean architecture, which can make it more maintainable, scalable, and reusable. By systematically testing your code, you can ensure that it works as intended in a variety of use cases.
Also, I would say that while testing you get to know a little bit more about your components. You can experiment with different scenarios and see how far can they go; and refactor when you see that it’s not working as intended (whether the code or the tests themselves).
Finally, It’s not only to debug an application but also a culture, a way of approaching the development process. Testing sets the standard of the application.
Well, it will depend on what languages and frameworks/libraries you use. But, here are some principles that I use to write tests:
Sometimes it's easier to test your components in their different functionalities and then test them together than testing all at once and trying to figure out where a possible bug could be.
Sometimes time we forget to check if the code we want to test sends a response to begin with, or even if it is even defined. So, test even the most fundamental things.
Try to test one thing at a time.
It's important to test not only the expected results but also the unexpected ones. By testing edge cases and error handling, you can ensure that your code is robust and can handle unexpected scenarios.
Mocks and stubs are tools that can help you isolate and test specific parts of your code. For example, if your code relies on an external API, you can use a mock API to simulate different responses and test how your code handles them.
Yes, that’s right, the idea is to improve code quality, so, use every failed test to solve it and hence improve the code and reliability of it.
Testing is important, but it's not realistic to test every single line of code. Instead, focus on testing the critical parts of your code and the parts that are most likely to break.
By following these principles and incorporating testing into your development process, you can build more reliable and maintainable software.
Even when you learn from courses, coworkers and tutorials, it’s also important to listen to your own experience and find your way to do it.
I’ll be releasing an article on testing in react native with this example that I made only for that article. Here’s the repository.
I don’t know if I’ll gonna release it after this article because I’ve been organizing my study notes and stuff. But I’ll let you know 😆 (And, yes, I did the thumbnail of this article. Pretty cool, right? 😎).
That’s it for me, but you can follow me on LinkedIn, Twitter, Instagram, Facebook, Github, Reddit and here in Hashnode. Also, you can subscribe to my newsletter down below 👇. Well, see ya!