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 tests perform precisely same operation each time they are run. Testers can program sophisticated tests to bring out hidden information.

Answer : C

Explanation

There must be at least two unit test cases for each requirement: one positive test and one negative test. If a requirement has sub-requirements, each sub-requirement must have at least two test cases as positive and negative.

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 assertNotNull(Object object) checks that an object isn't null.

Q 5 - Which of the following method of TestCase class runs a test, collecting the results with a default TestResult object?

A - TestResult runTestCase()

B - TestResult runTest()

C - TestResult runTestAndSave()

D - TestResult run()

Answer : D

Explanation

TestResult run() method runs a test, collecting the results with a default TestResult object.

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 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 - 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 Assertions for testing expected results.

A - true

B - false

Answer : A

Explanation

JUnit provides Assertions for testing expected results.

Q 10 - Fixture includes tearDown() method which runs after all test methods get executed.

A - true

B - false

Answer : B

Explanation

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

junit_questions_answers.htm
Advertisements