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

Answer : B

Explanation

Unit testing is the testing of single entity (class or method).

Q 2 - Which of the following tools provides JUnit integration?

A - Eclipse

B - Ant

C - Maven

D - All of the above.

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?

A - @Test

B - @Before

C - @After

D - @BeforeClass

Answer : B

Explanation

Annotating a public void method with @Before causes that method to be run before each Test method.

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)

C - void runTestAndSave (TestResult result)

D - void run (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?

A - void startTest(Test test)

B - void start(Test test)

C - void execute(Test test)

D - void executeTest(Test test)

Answer : A

Explanation

void startTest(Test test) method informs the result that a test will be started.

Answer : B

Explanation

void setName(String name) method sets the name of the suite.

Q 8 - @RunWith and @Suite annotation are used to run the suite test.

A - false

B - true

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.

A - true

B - false

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.

A - true

B - false

Answer : A

Explanation

TestCase contains a test case and defines the fixture to run multiple tests.

junit_questions_answers.htm
Advertisements