- 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?
A - JUnit tests can be organized into test suites containing test cases and even other test suites.
Answer : C
Explanation
JUnit tests can be organized into test suites containing test cases and even other test suites. JUnit shows test progress in a bar that is green if test is going fine and it turns red when a test fails in eclipse.
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 annotation causes that method run once after all tests have finished?
Answer : D
Explanation
Annotating a public static void method with @AfterClass cause that method run after all tests have finished. This can be used to perform clean-up activities.
Q 4 - Which of the following method of Assert class fails a test with no message?
A - void assertChecks(boolean pass)
Answer : D
Explanation
void fail() fails a test with no message.
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 informs the result that a test will be started?
Answer : A
Explanation
void startTest(Test test) method informs the result that a test will be started.
Q 7 - Which of the following method of TestSuite class returns a test which will fail and log a warning message?
A - static Test displayWarning(String message)
B - static Test showWarning(String message)
Answer : D
Explanation
int testCount() method returns a test which will fail and log a warning message.
Answer : B
Explanation
Both @RunWith and @Suite annotation are used to run the suite test.
Answer : B
Explanation
JUnit is an open source framework.
Answer : A
Explanation
Assert contains a set of assert methods.