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

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

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.

Q 5 - Which of the following method of TestResult class informs the result that a test was completed?

A - void showResult(Test test)

B - void getResult(Test test)

C - void endTest(Test test)

D - void startTest(Test test)

Answer : C

Explanation

void endTest(Test test) method informs the result that a test was completed.

Q 6 - Which of the following method of TestResult class gets the number of run tests?

A - int testCount()

B - int runCount()

C - int countExecutions()

D - int countRun()

Answer : B

Explanation

int runCount() method gets the number of run tests.

Q 7 - Which of the following method of TestSuite class returns the test at the given index?

A - Test testAt(int index)

B - Test testAtIndex(int index)

C - Test getTestAt(int index)

D - Test test(int index)

Answer : A

Explanation

Test testAt(int index) method returns the test at the given index.

Q 8 - Which of the following class is used to bundle unit test cases and run them together?

A - JUnitCore

B - TestCase

C - TestSuite

D - TestResult

Answer : C

Explanation

Test suite means bundle a few unit test cases and run it together.

Q 9 - Automation runs test cases significantly faster than human resources.

A - true

B - false

Answer : A

Explanation

Automation runs test cases significantly faster than human resources.

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