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

Manual testing is less reliable as tests may not be performed with precision each time because of human errors. No programming can be done to write sophisticated tests which fetch hidden information.

Q 2 - Which of the following class contains a set of assert methods?

A - Assert

B - TestCase

C - TestResult

D - TestSuite

Answer : A

Explanation

Assert class contains a set of assert methods.

Answer : C

Explanation

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

Q 5 - Which of the following method of TestCase class tears down the fixture, for example, close a network connection?

A - void tearDownTestName()

B - void tearDown()

C - void tearDownFixture()

D - void tearDownTestCase()

Answer : B

Explanation

void tearDown() method tears down the fixture.

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 - Annotating a public void method with @After causes that method to be run after each Test method.

A - false

B - true

Answer : B

Explanation

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

Q 8 - @Test annotation along with timeout attribute can be used to set timeout of a test case.

A - false

B - true

Answer : B

Explanation

@Test annotation along with timeout attribute can be used to set timeout of a test case.

Q 9 - Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

A - true

B - false

Answer : A

Explanation

Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

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