ExamGecko
Question list
Search
Search

Related questions











Question 25 - AD0-E134 discussion

Report
Export

A developer is on an AEM application that is being used to calculate an employee's salary. The calculation is done in an OSGi service called CalculationService. This service class has a dependency on one other service, called the EmployeeService.

How should the developer make sure that the critical code in the CalculationService has a high unit test coverage?

A.
Use a mock framework in the unit test to inject the CalculationService
Answers
A.
Use a mock framework in the unit test to inject the CalculationService
B.
Instantiate the EmployeeService in the unit test and pass it to the constructor of theCalculationService
Answers
B.
Instantiate the EmployeeService in the unit test and pass it to the constructor of theCalculationService
C.
Use a mock framework in the unit test to inject the EmployeeService
Answers
C.
Use a mock framework in the unit test to inject the EmployeeService
D.
Use the feature flag in the unit test to disable the calls to the EmployeeService
Answers
D.
Use the feature flag in the unit test to disable the calls to the EmployeeService
Suggested answer: C

Explanation:

A mock framework is a tool that allows creating mock objects that simulate the behavior of real objects in a controlled way. A mock framework can be used in a unit test to inject the

EmployeeService dependency into the CalculationService and verify its interactions. This way, the unit test can focus on testing the logic of the CalculationService without relying on the actual implementation of the EmployeeService. Reference:

https://sling.apache.org/documentation/development/sling-testing-tools.html

https://wcm.io/testing/aem-mock/usage.html

asked 02/10/2024
Mohsin Raza
43 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first