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

Explanation

All of the above options are correct.

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.

Answer : D

Explanation

The test cases are executed using JUnitCore class. JUnitCore is a facade for running tests. It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures.

Answer : C

Explanation

void assertNotSame(Object expected, Object actual) checks if two object references are not pointing to the same object.

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 counts the number of test cases that will be run by this test?

A - int countTestExecutions()

B - int countTest()

C - int count()

D - int countTestCases()

Answer : D

Explanation

int countTestCases() method counts the number of test cases that will be run by this test.

Q 7 - Annotating a public void method with @BeforeClass causes that method to be run before each Test method.

A - false

B - true

Answer : A

Explanation

Annotating a public static void method with @BeforeClass causes it to be run once before any of the test methods in the class.

Q 8 - The @Ignore annotation is used to ignore the test and that test will not be executed.

A - false

B - true

Answer : B

Explanation

The @Ignore annotation is used to ignore the test and that test will not be executed.

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 - Fixture includes setUp() method which runs once when test class loads.

A - true

B - false

Answer : B

Explanation

Fixture includes setUp() method which runs before every test invocation.

junit_questions_answers.htm
Advertisements