JUnit Online Quiz


Advertisements

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

Test suite means bundle a few unit test cases and run it together. In JUnit, both @RunWith and @Suite annotation are used to run the suite test.

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.

Answer : A

Explanation

void addError(Test test, Throwable t) method adds an error to the list of errors.

Q 6 - Which of the following method of TestResult class gets the number of detected failures?

A - int error()

B - int errorCount()

C - int failureCount()

D - int failure()

Answer : C

Explanation

int failureCount() method gets the number of detected failures.

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

A - false

B - true

Answer : B

Explanation

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

Q 8 - If a test class is annotated with @Ignore then none of its test methods will be executed.

A - false

B - true

Answer : B

Explanation

If a test class is annotated with @Ignore then none of its test methods will be executed.

Q 9 - Parameterized tests allow developer to run the same test over and over again using same values.

A - true

B - false

Answer : B

Explanation

Parameterized tests allow developer to run the same test over and over again using different values.

Q 10 - JUnit tests can be run automatically and they check their own results and provide immediate feedback.

A - true

B - false

Answer : A

Explanation

JUnit tests can be run automatically and they check their own results and provide immediate feedback.

junit_questions_answers.htm
Advertisements