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

JUnit tests can be organized into test suites containing test cases and even other test suites. JUnit shows test progress in a bar that is green if test is going fine and it turns red when a test fails in eclipse.

Answer : A

Explanation

Test runner is used for executing the test cases.

Q 3 - Which of the following annotation causes that method run once after all tests have finished?

A - @Test

B - @After

C - @BeforeClass

D - @AfterClass

Answer : D

Explanation

Annotating a public static void method with @AfterClass cause that method run after all tests have finished. This can be used to perform clean-up activities.

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

Explanation

void addFailure(Test test, AssertionFailedError t) method adds a failure to the list of failures.

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.

Q 7 - Which of the following method of TestSuite class returns a test which will fail and log a warning message?

A - static Test displayWarning(String message)

B - static Test showWarning(String message)

C - static Test getWarning(String message)

D - static Test warning(String message)

Answer : D

Explanation

int testCount() method returns a test which will fail and log a warning message.

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 - JUnit is a proprietory framework.

A - true

B - false

Answer : B

Explanation

JUnit is an open source framework.

Q 10 - Assert contains a set of assert methods.

A - true

B - false

Answer : A

Explanation

Assert contains a set of assert methods.

junit_questions_answers.htm
Advertisements