- 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 describes Unit Testing correctly?
B - Unit testing is the testing of single entity (class or method).
Answer : B
Explanation
Unit testing is the testing of single entity (class or method).
Q 2 - Which of the following tools provides JUnit integration?
Answer : D
Explanation
All of the above tools provides JUnit integration.
Q 3 - Which of the following annotation causes that method to be run before each Test method?
Answer : B
Explanation
Annotating a public void method with @Before causes that method to be run before each Test method.
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 runs the test case and collects the results in TestResult?
A - void runTestCase (TestResult result)
B - void runTest (TestResult result)
Answer : D
Explanation
void run (TestResult result) method runs the test case and collects the results in TestResult.
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 sets the name of the suite?
A - void setSuiteName(String name)
Answer : B
Explanation
void setName(String name) method sets the name of the suite.
Answer : B
Explanation
Both @RunWith and @Suite annotation are used to run the suite test.
Q 9 - Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.
Answer : A
Explanation
Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.
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.
To Continue Learning Please Login
Login with Google