Explore topic-wise MCQs in Junit.

This section includes 13 Mcqs, each offering curated multiple-choice questions to sharpen your Junit knowledge and support exam preparation. Choose a topic below to get started.

1.

What information does an object of the Failure class contain?

A. Description of the failed test
B. Description of the failed test and the exception thrown while running it
C. Description of the fail() method
D. Description of the exception thrown
Answer» C. Description of the fail() method
2.

What does the getRunCount() method of the Result return?

A. String denoting the time of execution
B. Integer denoting the time of execution
C. int denoting the number of tests run
D. int denoting the number of failed tests
Answer» D. int denoting the number of failed tests
3.

To run the file TestClass.class from the command line, we have to type what?

A. java TestClass
B. javac TestClass
C. java org.junit.runner.JUnitCore TestClass
D. org.junit.runner.JUnitCore TestClass
Answer» D. org.junit.runner.JUnitCore TestClass
4.

What is a Façade in JUnit?

A. It is a group of test cases
B. It is a design pattern that provides a unified interface to a set of interfaces in a subsystem
C. It is a collection of superclasses
D. It is a group of mock objects
Answer» C. It is a collection of superclasses
5.

WHAT_DOES_THE_GETRUNCOUNT()_METHOD_OF_THE_RESULT_RETURN??$

A. String denoting the time of execution
B. Integer denoting the time of execution
C. int denoting the number of tests run
D. int denoting the number of failed tests
Answer» C. int denoting the number of tests run
6.

TO_RUN_THE_FILE_TESTCLASS.CLASS_FROM_THE_COMMAND_LINE,_WE_HAVE_TO_TYPE_WHAT??$

A. java TestClass
B. javac TestClass
C. java org.junit.runner.JUnitCore TestClass
D. org.junit.runner.JUnitCore TestClass
Answer» D. org.junit.runner.JUnitCore TestClass
7.

When does the wasSuccessful() method of the Runner class return true?

A. The test file compiled
B. The test file ran
C. Some of the test cases ran successfully
D. All the test cases ran succesfully
Answer» D. All the test cases ran succesfully
8.

To listen to events during a test, which class has to be extended?

A. org.junit.runner.notification.RunListener
B. org.junit.runner.Listener
C. org.junit.runner.notification.Listener
D. org.junit.runner.RunListener
Answer» E.
9.

What type of object is returned on completion of a test?

A. org.junit.runner.Result
B. org.junit.runner.Complete
C. org.junit.runner.Outcome
D. org.junit.runner.Object
Answer» B. org.junit.runner.Complete
10.

To create a custom test runner which class needs to be extended?

A. CustomRunner
B. TestRunner
C. Runner
D. UserRunner
Answer» B. TestRunner
11.

What is a Façade in JUnit?$

A. It is a group of test cases
B. It is a design pattern that provides a unified interface to a set of interfaces in a subsystem
C. It is a collection of superclasses
D. It is a group of mock objects
Answer» C. It is a collection of superclasses
12.

To start a test case as JUnit 3.8 test case which runner is required?

A. org.junit.runners.Junit4
B. org.junit.runners.Parameterized
C. org.junit.internal.runners.Junit38ClassRunner
D. org.junit.internal.runners.Junit4
Answer» D. org.junit.internal.runners.Junit4
13.

JUnit runners are available in which package?

A. org.junit.runners
B. junitfiles.runners
C. org.runners
D. org.junit.files.runners
Answer» B. junitfiles.runners