Mocking Exceptions

Mocking Exceptions

Professional Development

17 Qs

quiz-placeholder

Similar activities

PL SQL

PL SQL

University - Professional Development

20 Qs

CAMBRIDGE - A Level - IT - Network Security

CAMBRIDGE - A Level - IT - Network Security

12th Grade - Professional Development

15 Qs

ExertnalLabExam_Web_Programming_CSE-1

ExertnalLabExam_Web_Programming_CSE-1

Professional Development

20 Qs

PLSQL_2324

PLSQL_2324

Professional Development

18 Qs

24/01/2024

24/01/2024

Professional Development

15 Qs

Integration of technology

Integration of technology

Professional Development

15 Qs

Behavioral patterns

Behavioral patterns

Professional Development

15 Qs

CYBER SECURITY

CYBER SECURITY

Professional Development

20 Qs

Mocking Exceptions

Mocking Exceptions

Assessment

Quiz

Computers

Professional Development

Practice Problem

Hard

Created by

ANIL KUMAR

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

17 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you mock exceptions in Mockito?

a) By using doThrow() and verify() methods.
b) By using when() and thenThrow() methods.
c) By using doReturn() and assertThrows() methods.
d) By using mock() and expect() methods.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is mocking in Java?

a) A process of removing all exceptions from code.
b) A technique to create controlled unit testing environments.
c) A method to ignore external dependencies in unit testing.
d) A process of simulating user interactions in Java applications.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to mock the checked exception in Java?

a) By using @Test(expectedExceptions = SomeException.class)
b) By using doThrow(new SomeException()) in mock objects.
c) By using catch blocks in test cases for checked exceptions.
d) By using mock() and expect() methods for checked exceptions.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you catch exceptions in Mockito?

a) By using catch blocks in test cases.
b) By using verify() and expect() methods.
c) By using assertThrows() and try-catch blocks.
d) By using try-catch blocks in test cases.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is an example of mock testing?

a) Validating calls without side effects and avoiding code duplication.
b) Simulating real user interactions in unit testing.
c) Testing exceptions by throwing them from mock objects.
d) Testing external dependencies in isolation.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to mock an error response?

a) By throwing an exception inside a request handler.
b) By composing a valid response using res() composition chain.
c) By simulating network errors in unit tests.
d) By using the mock() and expect() methods.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why do we use mocking?

a) To remove exceptions from the code.
b) To simulate user interactions in testing.
c) To isolate the code being tested from external dependencies.
d) To generate random test data.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?