- JUnit Tutorial
- JUnit - Home
- JUnit - Overview
- JUnit - Environment Setup
- JUnit - Test Framework
- JUnit - Basic Usage
- JUnit - API
- JUnit - Writing a Tests
- JUnit - Using Assertion
- JUnit - Execution Procedure
- JUnit - Executing Tests
- JUnit - Suite Test
- JUnit - Ignore Test
- JUnit - Time Test
- JUnit - Exceptions Test
- JUnit - Parameterized Test
- JUnit - Plug with Ant
- JUnit - Plug with Eclipse
- JUnit - Extensions
- JUnit Useful Resources
- JUnit - Questions and Answers
- JUnit - Quick Guide
- JUnit - Useful Resources
- JUnit - Discussion
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 is correct about JUnit?
Answer : C
Explanation
JUnit provides Test runners for running tests. JUnit tests can be run automatically and they check their own results and provide immediate feedback.
Q 2 - Which of the following class contains methods to collect the results of executing a test case?
Answer : C
Explanation
TestResult class contains methods to collect the results of executing a test case.
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?
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 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 runs a test, collecting the results with a default TestResult object?
Answer : D
Explanation
TestResult run() method runs a test, collecting the results with a default TestResult object.
Q 6 - Which of the following method of TestSuite class adds the tests from the given class to the suite?
A - void addTest(Class<? extends TestCase> testClass)
B - void addTestSuite(Class<? extends TestCase> testClass)
Answer : B
Explanation
void addTestSuite(Class<? extends TestCase> testClass) method adds the tests from the given class to the suite.
Q 7 - The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.
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 8 - @Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.
Answer : A
Explanation
@Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.
Answer : A
Explanation
JUnit provides Test runners for running tests.
Answer : B
Explanation
Fixture includes setUp() method which runs before every test invocation.
To Continue Learning Please Login
Login with Google