- 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 automated testing?
A - Automation tests perform precisely same operation each time they are run.
B - Testers can program sophisticated tests to bring out hidden information.
Answer : C
Explanation
Automation tests perform precisely same operation each time they are run. Testers can program sophisticated tests to bring out hidden information.
Q 2 - Which of the following is correct about Test Suite in JUnit?
A - Test suite means bundle a few unit test cases and run it together.
B - @RunWith and @Suite annotation are used to run the suite test.
Answer : C
Explanation
Test suite means bundle a few unit test cases and run it together. In JUnit, both @RunWith and @Suite annotation are used to run the suite test.
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 checks if two object references are not pointing to the same object?
A - void assert(Object expected, Object actual,boolean isSame)
B - void assertCheck(Object expected, Object actual,boolean isSame)
C - void assertNotSame(Object expected, Object actual)
D - void assertChecks(Object expected, Object actual,boolean isSame)
Answer : C
Explanation
void assertNotSame(Object expected, Object actual) checks if two object references are not pointing to the same object.
Q 5 - Which of the following method of TestCase class sets the name of a TestCase?
Answer : C
Explanation
void setName() method sets the name of a TestCase.
Q 6 - Which of the following method of TestResult class runs a TestCase?
B - void execute(TestCase test)
Answer : A
Explanation
void run(TestCase test) method runs a TestCase.
Q 7 - Which of the following method of TestSuite class runs the tests and collects their result in a TestResult?
A - void execute(TestResult result)
B - void runTest(TestResult result)
Answer : C
Explanation
void run(TestResult result) method runs the tests and collects their result in a TestResult.
Q 8 - The @Ignore annotation is used to ignore the test and that test will not be executed.
Answer : B
Explanation
The @Ignore annotation is used to ignore the test and that test will not be executed.
Answer : A
Explanation
JUnit 4.0 provides Annotations to identify the test methods.
Q 10 - TestCase contains a test case and defines the fixture to run multiple tests.
Answer : A
Explanation
TestCase contains a test case and defines the fixture to run multiple tests.