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

Explanation

Fixture is a fixed state of a set of objects used as a baseline for running tests. The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable.

Answer : C

Explanation

Method annotated as @After executes for each test case but after the execution of test case. In between method annotated as @Before and method annotated as @After each test case executes.

Answer : A

Explanation

void assertEquals(boolean expected, boolean actual) checks that two primitives/Objects are equal.

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

A - void setTestName()

B - void setNameOfTest()

C - void setName()

D - void setTestCase()

Answer : C

Explanation

void setName() method sets the name of a TestCase.

Q 6 - Which of the following method of TestResult class marks that the test run should stop?

A - void stopTest()

B - void stop()

C - void stopTest(Test test)

D - void breakTest(Test test)

Answer : B

Explanation

void stop() method marks that the test run should stop.

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 - Which of the following class is used to run test cases?

A - JUnitCore

B - TestCase

C - TestSuite

D - TestResult

Answer : A

Explanation

The test cases are executed using JUnitCore class.

Q 9 - Automated Test cases are executed by using automation tool so less tester are required in automation testing.

A - true

B - false

Answer : A

Explanation

Automated Test cases are executed by using automation tool so less tester are required in automation testing.

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

A - true

B - false

Answer : A

Explanation

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

junit_questions_answers.htm
Advertisements