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

Explanation

All of the above options are correct.

Q 2 - Which of the following class contains a set of assert methods?

A - Assert

B - TestCase

C - TestResult

D - TestSuite

Answer : A

Explanation

Assert class contains a set of assert methods.

Q 3 - Which of the following annotation causes that method to be run after each Test method?

A - @Test

B - @Before

C - @After

D - @AfterClass

Answer : C

Explanation

Annotating a public void method with @After causes that method to be run after each Test method.

Answer : B

Explanation

void assertTrue(boolean condition) checks that a condition is true.

Q 5 - Which of the following method of TestCase class sets up the fixture, for example, open a network connection?

A - void setTestName()

B - void setUp()

C - void setUpFixture()

D - void setTestCase()

Answer : B

Explanation

void setUp() method sets up the fixture.

Q 6 - Which of the following method of TestSuite class counts the number of test cases that will be run by this test?

A - int countTestExecutions()

B - int countTest()

C - int count()

D - int countTestCases()

Answer : D

Explanation

int countTestCases() method counts the number of test cases that will be run by this test.

Q 7 - Annotating a public void method with @Before causes that method to be run before each Test method.

A - false

B - true

Answer : B

Explanation

Annotating a public void method with @Before causes that method to be run before each Test method.

Q 8 - The @Ignore annotation is used to ignore the test and that test will not be executed.

A - false

B - true

Answer : B

Explanation

The @Ignore annotation is used to ignore the test and that test will not be executed.

Q 9 - Testing is the testing of single entity (class or method).

A - true

B - false

Answer : B

Explanation

Unit Testing is the testing of single entity (class or method). Testing is the process of checking the functionality of the application whether it is working as per requirements.

Q 10 - Assert contains a set of assert methods.

A - true

B - false

Answer : A

Explanation

Assert contains a set of assert methods.


junit_questions_answers.htm

Advertisements