- 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 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 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 JUnit execution procedure?
A - Method annotated as @After executes for each test case but after the execution of test case.
B - In between method annotated as @Before and method annotated as @After each test case executes.
Answer : C
Explanation
Method annotated as @After executes for each test case but after the execution of test case. In between method annotated as @Before and method annotated as @After each test case executes.
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 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 marks that the test run should stop?
Answer : B
Explanation
void stop() method marks that the test run should stop.
Q 7 - Which of the following method of TestSuite class returns the test at the given index?
Answer : A
Explanation
Test testAt(int index) method returns the test at the given index.
Q 8 - Which of the following class is used to run test cases?
Answer : A
Explanation
The test cases are executed using JUnitCore class.
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
Assert contains a set of assert methods.