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

Explanation

All of the above options are correct.

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.

Q 3 - Which of the following annotation tells JUnit that the public void method to which it is attached can be run as a test case?

A - @Test

B - @Before

C - @After

D - @BeforeClass

Answer : A

Explanation

The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

Answer : C

Explanation

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

Q 5 - Which of the following method of TestCase class gets the name of a TestCase?

A - String getTestName()

B - String getNameOfTest()

C - String getName()

D - String getTestCase()

Answer : C

Explanation

String getName() method gets the name of a TestCase.

Q 6 - Which of the following method of TestResult class gets the number of run tests?

A - int testCount()

B - int runCount()

C - int countExecutions()

D - int countRun()

Answer : B

Explanation

int runCount() method gets the number of run tests.

Q 7 - The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

A - true

B - false

Answer : A

Explanation

The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

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 - Parameterized tests allow developer to run the same test over and over again using same values.

A - true

B - false

Answer : B

Explanation

Parameterized tests allow developer to run the same test over and over again using different values.

Q 10 - Fixture includes tearDown() method which runs after all test methods get executed.

A - true

B - false

Answer : B

Explanation

Fixture includes tearDown() method which runs after every test method.

junit_questions_answers.htm
Advertisements