- 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 manual testing?
B - No programming can be done to write sophisticated tests which fetch hidden information.
Answer : C
Explanation
Manual testing is less reliable as tests may not be performed with precision each time because of human errors. No programming can be done to write sophisticated tests which fetch hidden information.
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 - 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 Assert class checks that a condition is false?
A - void assert(boolean condition)
B - void assertFalse(boolean condition)
Answer : B
Explanation
void assertFalse(boolean condition) checks that a condition is false.
Q 5 - Which of the following method of TestResult class adds an error to the list of errors?
A - void addError(Test test, Throwable t)
B - void addError(Test test, Error t)
Answer : A
Explanation
void addError(Test test, Throwable t) method adds an error to the list of errors.
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 - 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.
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.
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.