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.

Q 2 - Which of the following class contains methods to collect the results of executing a test case?

A - Assert

B - TestCase

C - TestResult

D - TestSuite

Answer : C

Explanation

TestResult class contains methods to collect the results of executing a test case.

Q 3 - Which of the following annotation causes that method to be run after each Test method?

A - @Test

B - @Before

C - @After

D - @AfterClass

Answer : C

Explanation

Annotating a public void method with @After causes that method to be run after each Test method.

Answer : C

Explanation

void assertNull(Object object) checks that an object is null.

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 TestSuite class adds a test to the suite?

A - void add(Test)

B - void add()

C - void addTest(Test test)

D - void addTestCase(Test test)

Answer : C

Explanation

void addTest(Test test) method adds a test to the suite.

Q 7 - Which of the following method of TestSuite class returns the number of tests in this suite?

A - int testCount()

B - int testCaseCount()

C - int getTestCount()

D - int testSuiteCount()

Answer : A

Explanation

int testCount() method returns the number of tests in this suite.

Q 8 - Which of the following class is used to run test cases?

A - JUnitCore

B - TestCase

C - TestSuite

D - TestResult

Answer : A

Explanation

The test cases are executed using JUnitCore class.

Q 9 - Automated Test cases are executed by using automation tool so less tester are required in automation testing.

A - true

B - false

Answer : A

Explanation

Automated Test cases are executed by using automation tool so less tester are required in automation testing.

Q 10 - Unit Tests are written after the code during development in order to help coders test the code.

A - true

B - false

Answer : B

Explanation

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

junit_questions_answers.htm
Advertisements