Unit test cases in Liferay 7.4 Update 50

thumbnail
Jamie Sammons, modified 2 Years ago. New Member Posts: 3 Join Date: 10/9/20 Recent Posts

Hello,

We need to write test cases into Liferay 7.4 Update 50, 

The module type is REST-BUILDER

Liferay generated testIntegration classes with it

Question: What is the correct way to write a unit test case in Rest Builder from below? 

  1. test (Mock the methods)
  2. testIntegration (Call the REST APIs from rest-client)

We have only GET-type APIs and we are using Web content to store the content.

Questions: How can we write the test cases for GET APIs when we don't have any API to create content (Test content)?

thumbnail
Olaf Kock, modified 2 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Personally, I tend to see REST APIs as wiring, not as the place to develop (testable) business-relevant code in. And the wiring is (on the unit-test level) enough to be reviewed - automated tests - including the actual REST layer - happen on a broader level, the integration tests.

Anything that's more than wiring should be extracted out and tested separately (and then it's IMHO rather obvious how to test).