- 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 describes Testing correctly?
B - Testing is the testing of single entity (class or method).
Answer : A
Explanation
Testing is the process of checking the functionality of the application whether it is working as per requirements.
Q 2 - Which of the following is correct about a Unit Test Case?
Answer : C
Explanation
There must be at least two unit test cases for each requirement: one positive test and one negative test. If a requirement has sub-requirements, each sub-requirement must have at least two test cases as positive and negative.
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 if two object references point to the same object?
A - void assert(Object expected, Object actual)
B - void assertCheck(Object expected, Object actual)
Answer : C
Explanation
void assertSame(Object expected, Object actual) checks if two object references point to the same object.
Q 5 - Which of the following method of TestCase class runs a test, collecting the results with a default TestResult object?
Answer : D
Explanation
TestResult run() method runs a test, collecting the results with a default TestResult object.
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 returns the test at the given index?
Answer : A
Explanation
Test testAt(int index) method returns the test at the given index.
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.
Answer : A
Explanation
Automation runs test cases significantly faster than human resources.
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.