
- 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 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 a Unit Test Case?
C - The known input should test a precondition and the expected output should test a postcondition.
Answer : D
Explanation
All of the above options are correct.
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 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 if two object references are not pointing to the same object?
A - void assert(Object expected, Object actual,boolean isSame)
B - void assertCheck(Object expected, Object actual,boolean isSame)
C - void assertNotSame(Object expected, Object actual)
D - void assertChecks(Object expected, Object actual,boolean isSame)
Answer : C
Explanation
void assertNotSame(Object expected, Object actual) checks if two object references are not pointing to the same object.
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 TestSuite class adds a test to the suite?
Answer : C
Explanation
void addTest(Test test) method adds a test to the suite.
Q 7 - Which of the following method of TestSuite class returns a test which will fail and log a warning message?
A - static Test displayWarning(String message)
B - static Test showWarning(String message)
Answer : D
Explanation
int testCount() method returns a test which will fail and log a warning message.
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.