- 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 class contains a set of assert methods?
Answer : A
Explanation
Assert class contains a set of assert methods.
Q 3 - Which of the following annotation causes that method run once before any of the test methods in the class?
Answer : C
Explanation
Annotating a public static void method with @BeforeClass causes it to be run once before any of the test methods in the class.
Q 4 - Which of the following method of Assert class checks that two primitives/Objects are equal?
A - void assertEquals(boolean expected, boolean actual)
B - void assert(boolean expected, boolean actual)
Answer : A
Explanation
void assertEquals(boolean expected, boolean actual) checks that two primitives/Objects are equal.
Q 5 - Which of the following method of TestResult class adds a failure to the list of failures?
A - void addFailure(Test test, Error t)
B - void addFailure(Test test, AssertionFailedError t)
Answer : B
Explanation
void addFailure(Test test, AssertionFailedError t) method adds a failure to the list of failures.
Q 6 - Which of the following method of TestResult class gets the number of detected failures?
Answer : C
Explanation
int failureCount() method gets the number of detected failures.
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 - @Test annotation along with timeout attribute can be used to set timeout of a test case.
Answer : B
Explanation
@Test annotation along with timeout attribute can be used to set timeout of a test case.
Answer : A
Explanation
Automation runs test cases significantly faster than human resources.
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.