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 assertArrayEquals(expectedArray, resultArray) checks whether two arrays are equal to each other.

Q 5 - Which of the following method of TestResult class informs the result that a test was completed?

A - void showResult(Test test)

B - void getResult(Test test)

C - void endTest(Test test)

D - void startTest(Test test)

Answer : C

Explanation

void endTest(Test test) method informs the result that a test was completed.

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 @BeforeClass causes that method to be run before each Test method.

A - false

B - true

Answer : A

Explanation

Annotating a public static void method with @BeforeClass causes it to be run once before any of the test methods in the class.

Q 8 - @Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.

A - true

B - false

Answer : A

Explanation

@Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.

Q 9 - Automation runs test cases significantly faster than human resources.

A - true

B - false

Answer : A

Explanation

Automation runs test cases significantly faster than human resources.

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