Unit testing is the process of testing your code in small blocks, or "units". The theory behind unit testing is very simple. By isolating a unit of code as much as possible and testing that it does what it's supposed to do you can check that the code works. Assuming all the units work properly, and that they don't 'magically' affect the way other parts of the code work, then there everything should work properly. When a block of code has side effects, making changes to things it really shouldn't change, then unforeseen bugs creep in.
In recent years there's been a bit of a a backlash against unit testing. The problem is that unit tests are often written in ways that fail to give you a good impression that they're really doing what they ought to do. It's easy to write tests that check simple things that would almost certainly have worked and hard to write tests that check the hard things that you really need to be checking. Consequently people didn't bother, and that makes unit testing a waste of time.
Unit testing can be worthwhile if you test the right things. This isn't simply because the tests tell you things are working, but because writing tests, and more importantly writing testable code, will improve your software. To test things you really need to think things through. That process is what makes code better. Unit tests are also useful if you work in a team. Occasionally you'll need to modify something that's hard to understand, or that requires understanding of lots of things at once. Having unit tests to check that code is working gives you more confidence to make changes. You still need to work hard to make modifications that work, but the unit tests will be there to make sure things haven't gone awry.
Writing unit tests
Assertions and expections
Buildup and teardown
Mocks and spys
Configuring your test runner