JUnit Online Quiz


Following quiz provides Multiple Choice Questions (MCQs) related to JUnit Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : C

Explanation

JUnit provides Test runners for running tests. JUnit tests can be run automatically and they check their own results and provide immediate feedback.

Answer : A

Explanation

Test runner is used for executing the test cases.

Q 3 - Which of the following class is a Composite of Tests?

A - Assert

B - TestCase

C - TestResult

D - TestSuite

Answer : D

Explanation

TestSuite class is a Composite of Tests.

Q 4 - Which of the following method of Assert class fails a test with no message?

A - void assertChecks(boolean pass)

B - void assertCheck(boolean pass)

C - void assert(boolean pass)

D - void fail()

Answer : D

Explanation

void fail() fails a test with no message.

Q 5 - Which of the following method of TestCase class runs a test, collecting the results with a default TestResult object?

A - TestResult runTestCase()

B - TestResult runTest()

C - TestResult runTestAndSave()

D - TestResult run()

Answer : D

Explanation

TestResult run() method runs a test, collecting the results with a default TestResult object.

Answer : A

Explanation

void run(TestCase test) method runs a TestCase.

Q 7 - Which of the following method of TestSuite class returns the name of the suite?

A - String getNameOfTestSuite()

B - String getTestName()

C - String getName()

D - String getTestSuite()

Answer : C

Explanation

String getName() method returns the name of the suite.

Q 8 - Annotating a public void method with @AfterClass causes that method to be run after each Test method.

A - false

B - true

Answer : A

Explanation

@AfterClass will perform the method after all tests have finished. This can be used to perform clean-up activities.

Q 9 - JUnit is a proprietory framework.

A - true

B - false

Answer : B

Explanation

JUnit is an open source framework.

Q 10 - Fixture includes setUp() method which runs once when test class loads.

A - true

B - false

Answer : B

Explanation

Fixture includes setUp() method which runs before every test invocation.

junit_questions_answers.htm
Advertisements