![JUnit Tutorial](/junit/images/junit-mini-logo.jpg)
- 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.
![Questions and Answers](/images/questions_and_answers.png)
Q 1 - Which of the following is correct about JUnit?
A - It is an open source framework.
B - It provides Annotation to identify the test methods.
Answer : D
Explanation
All of the above options are correct.
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 is correct about org.junit.JUnitCore class?
A - The test cases are executed using JUnitCore class.
B - JUnitCore is a facade for running tests.
C - It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.
Answer : D
Explanation
The test cases are executed using JUnitCore class. JUnitCore is a facade for running tests. It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.
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 tears down the fixture, for example, close a network connection?
Answer : B
Explanation
void tearDown() method tears down the fixture.
Q 6 - Which of the following method of TestSuite class counts the number of test cases that will be run by this test?
Answer : D
Explanation
int countTestCases() method counts the number of test cases that will be run by this test.
Q 7 - Annotating a public void method with @BeforeClass causes that method to be run before each Test method.
Answer : A
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 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
Automation runs test cases significantly faster than human resources.
Answer : B
Explanation
Fixture includes setUp() method which runs before every test invocation.