Unit testing

I finished my first unit test course, and it made me confused!
In the course, we used Mocha + Chai to build a small app with the BBD approach.
I got the idea of why should I build the test first and then write the code. But I don’t understand when and what?
Should I use testing even for small apps? Should I test every code that I intend to write?
And how can I continue to learn about testing? Can you recommend me a good video course?


1 Like


The only way to get good at testing is to practice it a lot.

The basic idea is that you write a test that expresses what you think you want your code to do. Then you write the smallest amount of code you can to make the test pass. Then write the next test and repeat.

The failing part is important as it is what lets you know that your test is helping.

I would test code based on if you intend to keep it. If you write some code to do one thing and plan to throw it out later then don’t bother, but something that is important and you want to keep . That should have tests

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.