Use the debugger to write it. You will find that it is a lot easier to write code this way when you can see all the context for a method. The main drawback with this technique is that your code is more haphazard, reflecting the different alternatives you tried. Workspaces are not permanent, so you quickly lose tests in workspaces. It is useful to keep tests around so you can run them again after you make changes to your code.
Tests can also be useful for documentation.
Finally, sometimes management requires you to hand in your tests. One way is to store the tests for a method as comments at the beginning of the method. This makes it easy to use them as documentation for the method, and ensures that when you delete the method that you will delete its tests. It also makes it easy to update tests when the method changes. On the other hand, this does not let you run all the tests for a class, and it can make methods less readable when the number of tests grows.