Hema Venkatrangan tackles the issue of testing JSR168 portlets in this introduction to portletUnit.

"As the saying goes, 'If a program feature lacks an automated test, we assume it doesn't work.' The goal of unit testing is to verify whether the smallest unit of code behaves the way it is expected to. Unit testing defines a written contract about the behavior of each unit. Each unit, defined at the method level, is tested separately before integration with its respective modules. Unit testing is the safe way to ensure that your feature will work today and forever. Testing can prove whether the application can run effectively in any environment. If it can't, the application has to be redesigned based on requirements."