updated 21 April 2022
I was too intimidated by the f*ckin' concept of code testing. Why will you test your motherf*ckin' code in the first place? Do you not trust your own code? Will it not work as intended?
Oh, you gonna love this: But then by reading so much about this, I fully got the goddamn hang of it. So here it goes:
Without the automated code testing, the tendency is to test your damn code by running the entire program and manually testing it. So, you are still testing it without being aware of it.
For example, for students doing programming in Robotics, since their motherf*ckin' focus is just to know whether their code is actually working, they will be manually running the muthaf*ckin' code from time to time. Check it: If the code did not work as intended, then they will trace the problem. This entire process is being repeated and is actually time consuming particularly when the code is getting longer and longer. And take note, it is not yet one big project. Get this sh*t: But testing is already there, they are just doing it manually.
As was mentioned from my example, if you don't have any idea about code testing, well I say, you are doing it without being aware of it. The tendency is to run the whole program and manually test whether each goddamn part of the code is working as intended.
Now, this is only practical if your project is just a small one. Pay attention: But software development nowadays is already a f*ckin' sophisticated one. Check it: So, testing it manually will surely be a headache. Plus, it is not that efficient. And even a goddamn well-tested code will not always work as intended to be, muthaf*cka. Our role is just to minimize errors and maintain the damn code.
Others are really goddamn confused about these two things, are you testing while you are debugging? Or conversely, are you debugging while you are testing?
Debugging was a motherf*ckin' popular practice before
the term code testing was coined. And hell yes,
developers back then manually test
their damn code. And they
were referring to testing as part of
debugging, without, of course, the muthaf*ckin' knowledge
of it. But there came a time,
it was recognized as a separate process.
And of course, software development
has been continuously evolving, testing
now is a very sophisticated one: there
are technologies just for testing alone.
So testing now becomes the way to actually look for system errors and debugging is the process of solving these motherf*ckin' errors. Hence, debugging is a manual task to be done by a talented debugger or the f*ckin' developer himself while testing, the act of finding errors, is mostly automated through coding. By making testing an automated one, you save time and effort, since you don't need to run the entire program just to see whether your code is working as it is intended to be.
Unit tests and integration tests are the most common tests that are being referred to mainly because these muthaf*ckin' two tests should be done (most of the time) by the developer himself.
There are on-going debates as to what is considered a unit, say, it can be a component of a program and whether you test first before you code and whether every line of code should be tested. Of course, development is up to the muthaf*ckin' programmer or the company in what they believe is the best for them.
Integration tests, on the other hand, are tests when you are combining several components: will they still work as intended? Problems arise when there is too much dependence in a muthaf*ckin' program. So mainly, even testing is just in your f*ckin' mind, it will affect the way you use global variables and components that are dependent on one another.
For me, personally, I write unit tests and integration tests for my muthaf*ckin' projects.
Hold the f*ck up — In my experience, I had developed the projects first without any idea about code testing. So I wrote them backwards. Goddamn. With that, I refactored everything in such a way that:
- a function will return just one value
- components should not be dependent on any other part of the program, if the damn developer can avoid it
- return values should be handled by arguments and should be returned properly (remember, rule no. 2)
- global variables should be used minimally and should be closely monitored
- throwing exceptions should be closely monitored through testing because throwing muthaf*ckin' exceptions are actually tricky
Then, the effect was immediate the very first time I did this: when I looked at the code, it was really neat.
So, from that point in time, I realized I need to include code testing in my workflow. But I just write unit tests for components or functions that I feel I really need to focus on.
This only means that a developer should not find it difficult to write unit and integration tests, if he/she finds it difficult, the f*ckin' source code is really not that neat.
But others will still insist, they are good and excellent coders and very careful writing quality code. I say I had the same feeling but even if you just started thinking whether your code is testable, you will have a muthaf*ckin' different approach. You will see things in a muthaf*ckin' different perspective, for real. It's just like you looking at your work just like other persons in charge of checking your code. Remember that others see errors better than ourselves.
Other tests just like black box testing will be done by another person, usually a tester. This is another layer of testing for quality assurance. Think about that sh*t. Don't you know that bugs can cause million dollars to be just wasted, muthaf*cka? Get this sh*t: So, a company really goddamn needs this kind of quality assurance.
You can check out my damn actual codes with unit and integration tests:
https://github.com/jdevstatic/java
Here are the motherf*ckin' detailed tutorials for this code testing:
https://www.toptal.com/qa/how-to-write-testable-code-and-why-it-matters
https://www.zeolearn.com/magazine/what-is-code-testing-and-why-is-it-important
https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html