- 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 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 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 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 TestCase class counts the number of test cases executed by run(TestResult result)?
Answer : A
Explanation
int countTestCases() method counts the number of test cases executed by run(TestResult result).
Q 5 - Which of the following method of TestCase class runs the test case and collects the results in TestResult?
A - void runTestCase (TestResult result)
B - void runTest (TestResult result)
Answer : D
Explanation
void run (TestResult result) method runs the test case and collects the results in TestResult.
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 - 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 - 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.
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.
Q 10 - JUnit tests can be run automatically and they check their own results and provide immediate feedback.
Answer : A
Explanation
JUnit tests can be run automatically and they check their own results and provide immediate feedback.