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

Explanation

Automation tests perform precisely same operation each time they are run. Testers can program sophisticated tests to bring out hidden information.

Answer : A

Explanation

Test runner is used for executing the test cases.

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.

Q 4 - Which of the following method of Assert class fails a test with no message?

A - void assertChecks(boolean pass)

B - void assertCheck(boolean pass)

C - void assert(boolean pass)

D - void fail()

Answer : D

Explanation

void fail() fails a test with no message.

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.

Answer : B

Explanation

void addTestSuite(Class<? extends TestCase> testClass) method adds the tests from the given class to the suite.

Q 7 - Which of the following method of TestSuite class returns the test at the given index?

A - Test testAt(int index)

B - Test testAtIndex(int index)

C - Test getTestAt(int index)

D - Test test(int index)

Answer : A

Explanation

Test testAt(int index) method returns the test at the given index.

Q 8 - @RunWith and @Suite annotation are used to run the suite test.

A - false

B - true

Answer : B

Explanation

Both @RunWith and @Suite annotation are used to run the suite test.

Q 9 - JUnit 4.0 provides Annotations to identify the test methods.

A - true

B - false

Answer : A

Explanation

JUnit 4.0 provides Annotations to identify the test methods.

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