JUnit Online Quiz


Advertisements


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 : A

Explanation

Unit Tests are to be written before the code during development in order to help coders write the best code.

Answer : D

Explanation

The test cases are executed using JUnitCore class. JUnitCore is a facade for running tests. It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.

Q 4 - Which of the following method of TestCase class counts the number of test cases executed by run(TestResult result)?

A - int countTestCases()

B - int executedTestCases()

C - int getTestCaseCount()

D - int testCases()

Answer : A

Explanation

int countTestCases() method counts the number of test cases executed by run(TestResult result).

Q 5 - Which of the following method of TestCase class creates a default TestResult object?

A - TestResult getTestResult()

B - TestResult createResult()

C - TestResult getTestResultInstance()

D - TestResult testResult()

Answer : B

Explanation

TestResult createResult() method creates a default TestResult object.

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

A - int error()

B - int errorCount()

C - int failureCount()

D - int failure()

Answer : C

Explanation

int failureCount() method gets the number of detected failures.

Q 7 - Which of the following method of TestSuite class returns the test at the given index?

A - Test testAt(int index)

B - Test testAtIndex(int index)

C - Test getTestAt(int index)

D - Test test(int index)

Answer : A

Explanation

Test testAt(int index) method returns the test at the given index.

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 provides Test runners for running tests.

A - true

B - false

Answer : A

Explanation

JUnit provides Test runners for running tests.

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