Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Junit testing in Liferay 6.2 for custom portlets(service portlets)
Hi please suggest me in writing the unit testcases(mocking of Objects for the services) for the custom portlet, which has the dependency with other service portlet in liferay 6.2(please give the clarity with the full pledged example), which uses junit and mockito...
Thanks
Thanks
Ganesh Pulithis might take a couple of weeks, especially given that we know nothing other than "everything is custom"...
...(please give the clarity with the full pledged example)...
Apart from that I'd say: Extract all the unit-testable code out of your portlet, so that the portlet remains a bit of the UI-layer that's largely wiring and can be reviewed. Unit-Test the heck out of the extracted code. Have your business code behind the service layer, again: Extract the testable code and behavior, to make it as independent of the persistence layer as possible. Then test the extracted code.
Reduce the code that you currently intend to mock. Turn it down to wiring the components to the APIs used. Unit testing a portlet is inherently hard, as it's on the UI layer - and unit testing UI is hard. I've not seen a lot of cases where mocking helped a great deal other than approving the implementation didn't change (but not any correctness).
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™