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.

Q 2 - Which of the following tools provides JUnit integration?

A - Eclipse

B - Ant

C - Maven

D - All of the above.

Answer : D

Explanation

All of the above tools provides JUnit integration.

Answer : C

Explanation

void assertNull(Object object) checks that an object is null.

Q 5 - Which of the following method of TestCase class tears down the fixture, for example, close a network connection?

A - void tearDownTestName()

B - void tearDown()

C - void tearDownFixture()

D - void tearDownTestCase()

Answer : B

Explanation

void tearDown() method tears down the fixture.

Q 6 - Which of the following method of TestResult class gets the number of detected errors?

A - int getErrors()

B - int errorCount()

C - int countErrors()

D - int getErrorCount()

Answer : B

Explanation

int errorCount() method gets the number of detected errors.

Q 7 - Which of the following method of TestSuite class runs the tests and collects their result in a TestResult?

A - void execute(TestResult result)

B - void runTest(TestResult result)

C - void run(TestResult result)

D - void executeTest(TestResult result)

Answer : C

Explanation

void run(TestResult result) method runs the tests and collects their result in a TestResult.

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 - Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

A - true

B - false

Answer : A

Explanation

Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

Q 10 - Eclipse supports JUnit integration using its plugin.

A - true

B - false

Answer : A

Explanation

Eclipse supports JUnit integration using its JUnit plugin.

junit_questions_answers.htm
Advertisements