I work as an independent developer. I find it difficult to test functionality of a feature and test code. As project goes complex, I loose focus resulting in each feature partially developed. I want to know how to write test cases, manage smooth workflow and handle features effectively and while remain focused?
Creating a backlog of requirements/user stories can help focus on what needs to be done and when it needs doing. For each iteration you can decide what you want to achieve and how much time you want to dedicate to it. Try to strike a balance between keeping yourself busy and avoiding biting off more than you can chew though - both extremes can be demoralising.
If you feel yourself getting bored or losing focus, try switching to another user story. Remember that it is often the case that a change is as good as a rest. With a good DVCS like git or mercurial you can easily switch contexts by switching branches. When sets of features are ready at the end of a sprint, merge them together and you have a sound basis for the next iteration.
Finally, TDD can really help focus the mind on what you need right now (YAGNI) and it strongly encourages you to write your code with testability in mind. It takes me about the same time to write code using TDD as it takes me to write without it, but with TDD subsequent debugging, re-factoring and regression testing are all much cheaper and can be done with much more confidence.
Staying focused while working on your own, be it personal projects or freelancing, is certainly a challenge. Here are some tips for what I'd try to consider (and use myself whenever I'm dealing with these kind of projects):
In addition to what Andiaz said:
Increase modularity in your project.
Keep doin the unit-testing in parallel to your development work
Use a versioning software like they do in big companies. (Dont know if these softwares have free versions)
Decide and follow your own procedure for development process. Keep doin reviews.
One suggestion: Read some Software Eng. book, like Pressman.