Testing your Play! controllers
Join the DZone community and get the full member experience.
Join For Free
Lets say you have a controller like this (from the Play! documentation)
And you want to write a test to check the render parameters are correct, how do you do that?
Well here is a little example
You might want to put the getRenderParameter in a separate class to easily reuse it.
If you want to test a controller method that take parameters is as easy.
Let's assume you want to test a simple controller method in Users called getUserByUsername to make sure the correct user is added to render when the form is submitted
In this case the test would be
Please feel free to comment!
And you want to write a test to check the render parameters are correct, how do you do that?
Well here is a little example
You might want to put the getRenderParameter in a separate class to easily reuse it.
If you want to test a controller method that take parameters is as easy.
Let's assume you want to test a simple controller method in Users called getUserByUsername to make sure the correct user is added to render when the form is submitted
In this case the test would be
Please feel free to comment!
Topics:
Opinions expressed by DZone contributors are their own.
Comments