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

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 before each Test method?

A - @Test

B - @Before

C - @After

D - @BeforeClass

Answer : B

Explanation

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

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 TestSuite class adds a test to the suite?

A - void add(Test)

B - void add()

C - void addTest(Test test)

D - void addTestCase(Test test)

Answer : C

Explanation

void addTest(Test test) method adds a test to the suite.

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 bundle unit test cases and run them together?

A - JUnitCore

B - TestCase

C - TestSuite

D - TestResult

Answer : C

Explanation

Test suite means bundle a few unit test cases and run it together.

Q 9 - JUnit is a proprietory framework.

A - true

B - false

Answer : B

Explanation

JUnit is an open source framework.

Q 10 - TestCase contains a test case and defines the fixture to run multiple tests.

A - true

B - false

Answer : A

Explanation

TestCase contains a test case and defines the fixture to run multiple tests.


junit_questions_answers.htm

Advertisements