Unit testing and debugging are two totally different things:

You do unit testing after you have completed your code, to find out any problems it might have.

Once you find out a problem, you debug your code to find the exact reason for the problem and to fix it.