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 : C

Explanation

Automation runs test cases significantly faster than human resources. Test cases are executed by using automation tool so less tester are required in automation testing.

Answer : A

Explanation

Unit Tests are to be written before the code during development in order to help coders write the best code.

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 fails a test with no message?

A - void assertChecks(boolean pass)

B - void assertCheck(boolean pass)

C - void assert(boolean pass)

D - void fail()

Answer : D

Explanation

void fail() fails a test with no message.

Q 5 - Which of the following method of TestCase class gets the name of a TestCase?

A - String getTestName()

B - String getNameOfTest()

C - String getName()

D - String getTestCase()

Answer : C

Explanation

String getName() method gets the name of a TestCase.

Q 6 - Which of the following method of TestResult class returns an Enumeration for the errors?

A - Enumeration<Object> errors()

B - Enumeration<TestFailure> errors()

C - Enumeration<TestFailure> getErrors()

D - Enumeration<Object> getErrors()

Answer : C

Explanation

Enumeration<TestFailure> errors() method returns an Enumeration for the errors.

Q 7 - The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

A - true

B - false

Answer : A

Explanation

The @Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

Q 8 - Annotating a public void method with @AfterClass causes that method to be run after each Test method.

A - false

B - true

Answer : A

Explanation

@AfterClass will perform the method after all tests have finished. This can be used to perform clean-up activities.

Q 9 - JUnit provides Test runners for running tests.

A - true

B - false

Answer : A

Explanation

JUnit provides Test runners for running tests.

Q 10 - Fixture includes tearDown() method which runs after every test method.

A - true

B - false

Answer : A

Explanation

Fixture includes tearDown() method which runs after every test method.

junit_questions_answers.htm
Advertisements