Unit test cases in Liferay 7.4 Update 50

thumbnail
Jamie Sammons,修改在3 年前。 New Member 帖子: 3 加入日期: 20-10-9 最近的帖子

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,修改在3 年前。 Liferay Legend 帖子: 6441 加入日期: 08-9-23 最近的帖子

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).