- 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 describes Unit Testing correctly?
B - Unit testing is the testing of single entity (class or method).
Answer : B
Explanation
Unit testing is the testing of single entity (class or method).
Q 2 - Which of the following is correct about Test Runner in JUnit?
A - Test runner is used for executing the test cases.
B - @RunWith and @Suite annotation are used to run the test runner.
Answer : A
Explanation
Test runner is used for executing the test cases.
Q 3 - Which of the following is correct about org.junit.JUnitCore class?
A - The test cases are executed using JUnitCore class.
B - JUnitCore is a facade for running tests.
C - It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.
Answer : D
Explanation
The test cases are executed using JUnitCore class. JUnitCore is a facade for running tests. It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.
Q 4 - Which of the following method of Assert class checks that a condition is true?
A - void assert(boolean condition)
B - void assertTrue(boolean condition)
Answer : B
Explanation
void assertTrue(boolean condition) checks that a condition is true.
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 counts the number of test cases that will be run by this test?
Answer : D
Explanation
int countTestCases() method counts the number of test cases that will be run by this test.
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 - Which of the following class is used to bundle unit test cases and run them together?
Answer : C
Explanation
Test suite means bundle a few unit test cases and run it together.
Answer : B
Explanation
Unit Testing is the testing of single entity (class or method). Testing is the process of checking the functionality of the application whether it is working as per requirements.
Answer : A
Explanation
Fixture includes tearDown() method which runs after every test method.