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

Explanation

Testing is the process of checking the functionality of the application whether it is working as per requirements.

Answer : C

Explanation

Fixture includes setUp() method which runs before every test invocation and tearDown() method which runs after every test method.

Q 3 - Which of the following annotation causes that method to be run after each Test method?

A - @Test

B - @Before

C - @After

D - @AfterClass

Answer : C

Explanation

Annotating a public void method with @After causes that method to be run after each Test method.

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 tears down the fixture, for example, close a network connection?

A - void tearDownTestName()

B - void tearDown()

C - void tearDownFixture()

D - void tearDownTestCase()

Answer : B

Explanation

void tearDown() method tears down 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 - Annotating a public void method with @After causes that method to be run after each Test method.

A - false

B - true

Answer : B

Explanation

Annotating a public void method with @After causes that method to be run after each Test method.

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 provides Assertions for testing expected results.

A - true

B - false

Answer : A

Explanation

JUnit provides Assertions for testing expected results.

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