A framework is not absolutely necessary: it is “just” one of the tools that is available to help you develop better and faster!
Better, because a framework provides you with the certainty that you are developing an application that is in full compliance with the business rules, that is structured, and that is both maintainable and upgradable.
Faster, because it allows developers to save time by re-using generic modules in order to focus on other areas. Without, however, ever being tied to the framework itself.
In automation testing you should be using any tool, which definitely need code to write. For example if you use webdriver for automation, you need to write code in java/python/ruby etc. So for developing that you can use any frameworks like TestNG, JUnit , PhpUnit etc.