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.
Q 1 - Which of the following describes Testing correctly?
B - Testing is the testing of single entity (class or method).
Answer : A
Explanation
Testing is the process of checking the functionality of the application whether it is working as per requirements.
Q 2 - Which of the following is correct about Fixture?
A - Fixture includes setUp() method which runs before every test invocation.
B - Fixture includes tearDown() method which runs after every test method.
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?
Answer : C
Explanation
Annotating a public void method with @After causes that method to be run after each Test method.
Q 4 - Which of the following method of Assert class checks that two primitives/Objects are equal?
A - void assertEquals(boolean expected, boolean actual)
B - void assert(boolean expected, boolean actual)
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?
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?
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.
Answer : B
Explanation
Annotating a public void method with @After causes that method to be run after each Test method.
Answer : B
Explanation
Both @RunWith and @Suite annotation are used to run the suite test.
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.
Answer : B
Explanation
Unit Tests are to be written before the code during development in order to help coders write the best code.