- 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 tools provides JUnit integration?
Answer : D
Explanation
All of the above tools provides JUnit integration.
Q 3 - Which of the following is correct about JUnit execution procedure?
A - First of all method annotated as @BeforeClass execute only once.
B - Lastly, the method annotated as @AfterClass executes only once.
C - Method annotated as @Before executes for each test case but before executing the test case.
Answer : D
Explanation
All of the above options are correct.
Q 4 - Which of the following method of Assert class checks that an object is null?
A - void assert(Object object, boolean toCheckAsNull)
B - void assertCheck(Object object, boolean toCheckAsNull)
Answer : C
Explanation
void assertNull(Object object) checks that an object is null.
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 gets the number of detected errors?
Answer : B
Explanation
int errorCount() method gets the number of detected errors.
Q 7 - Which of the following method of TestSuite class runs the tests and collects their result in a TestResult?
A - void execute(TestResult result)
B - void runTest(TestResult result)
Answer : C
Explanation
void run(TestResult result) method runs the tests and collects their result in a TestResult.
Q 8 - Annotating a public void method with @AfterClass causes that method to be run after each Test method.
Answer : A
Explanation
@AfterClass will perform the method after all tests have finished. This can be used to perform clean-up activities.
Q 9 - Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.
Answer : A
Explanation
Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.
Answer : A
Explanation
Eclipse supports JUnit integration using its JUnit plugin.
To Continue Learning Please Login
Login with Google