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.

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.

Q 3 - Which of the following annotation causes that method run once before any of the test methods in the class?

A - @Test

B - @Before

C - @BeforeClass

D - @AfterClass

Answer : C

Explanation

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

Answer : B

Explanation

void assertFalse(boolean condition) checks that a condition is false.

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 - Which of the following method of TestSuite class returns the name of the suite?

A - String getNameOfTestSuite()

B - String getTestName()

C - String getName()

D - String getTestSuite()

Answer : C

Explanation

String getName() method returns the name of the suite.

Q 8 - @Test annotation along with timeout attribute can be used to set timeout of a test case.

A - false

B - true

Answer : B

Explanation

@Test annotation along with timeout attribute can be used to set timeout of a test case.

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 - Unit Tests are written after the code during development in order to help coders test the code.

A - true

B - false

Answer : B

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