My boss at work decided it would be a good idea to write unit tests for a Java program I've been working on for a while. The program is your fairly typical mess, but it isn't huge. I've never used or written any unit tests before, and from everything I've read on the subject a pre-existing project is not the best place to start. I don't really have a choice though, so I have some questions.
My main question is this: I've read a lot of things about what unit tests should do, what their scope should be, how to write production code in a TDD process, etc. I have yet to find anyone who talks about where the code should actually go. Do I write my tests in the production code classes themselves? Do I put all of them in a separate .java file (or files)? Do I put them in their own directory in the project? If I use either of the latter options, how would I access private objects and methods in order to test them? I feel like this should be a fairly obvious question, but I just don't know.
And a secondary question: I've seen a lot of convincing arguments for using TDD, and I would like to try it in my personal projects. Would whatever the answer to my first question is hold true for starting completely new projects? Or would I implement unit tests differently for pre-existing projects as opposed to new ones?