26.Setup Mocks

26.Setup Mocks

Assessment

Quiz

Education

Professional Development

Hard

Created by

ANIL KUMAR

FREE Resource

Student preview

quiz-placeholder

49 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to create a mock in Java?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Download a Mockito-All archive and set up the Mockito environment.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).
A mock is a fake class that can be examined after the test is finished for its interactions with the class under test.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do I set up Mockito?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Download a Mockito-All archive and set up the Mockito environment.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).
A mock is a fake class that can be examined after the test is finished for its interactions with the class under test.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to initialize mock object in Java?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Download a Mockito-All archive and set up the Mockito environment.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).
A mock is a fake class that can be examined after the test is finished for its interactions with the class under test.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is @mock in Java?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Download a Mockito-All archive and set up the Mockito environment.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).
A mock is a fake class that can be examined after the test is finished for its interactions with the class under test.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between @InjectMocks and Autowired?
@InjectMocks is a Mockito mechanism for injecting declared fields in the test class into matching fields in the class under test, while @Autowired is Spring's annotation for autowiring a bean into a production, non-test class.
@InjectMocks is a Mockito mechanism for injecting declared fields in the test class into matching fields in the class under test, and it requires the class under test to be a Spring component, while @Autowired is Spring's annotation for autowiring a bean into a production, non-test class.
@InjectMocks is a Mockito mechanism for injecting declared fields in the test class into matching fields in the class under test, and it doesn't require the class under test to be a Spring component, while @Autowired is Spring's annotation for autowiring a bean into a production, non-test class.
@InjectMocks is a Mockito mechanism for injecting declared fields in the test class into matching fields in the class under test, while @Autowired is Spring's annotation for autowiring a bean into a production, non-test class.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to create mock for API?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Set up a collection for mocking, retrieve the collection ID, create a mock server with the Postman API, and send a request to the mock server.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).
A mock is a fake class that can be examined after the test is finished for its interactions with the class under test.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can a mock be created?
Create fake objects from real classes/interfaces and instrument them to respond with specific data for each method.
Download a Mockito-All archive and set up the Mockito environment.
Create an interface and a Java class to represent the application, test the class, and verify the result.
Call MockitoAnnotations.initMocks(this) in a setup method or use annotations like @RunWith(MockitoJUnitRunner.class) or @ExtendWith(MockitoExtension.class).

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?