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

Manual testing is less reliable as tests may not be performed with precision each time because of human errors. No programming can be done to write sophisticated tests which fetch hidden information.

Answer : A

Explanation

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

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 assertSame(Object expected, Object actual) checks if two object references point to the same object.

Q 5 - Which of the following method of TestCase class sets up the fixture, for example, open a network connection?

A - void setTestName()

B - void setUp()

C - void setUpFixture()

D - void setTestCase()

Answer : B

Explanation

void setUp() method sets up the fixture.

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 number of tests in this suite?

A - int testCount()

B - int testCaseCount()

C - int getTestCount()

D - int testSuiteCount()

Answer : A

Explanation

int testCount() method returns the number of tests in this suite.

Q 8 - The @Ignore annotation is used to ignore the test and that test will not be executed.

A - false

B - true

Answer : B

Explanation

The @Ignore annotation is used to ignore the test and that test will not be executed.

Q 9 - Parameterized tests allow developer to run the same test over and over again using same values.

A - true

B - false

Answer : B

Explanation

Parameterized tests allow developer to run the same test over and over again using different values.

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