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

JUnit tests can be organized into test suites containing test cases and even other test suites. JUnit shows test progress in a bar that is green if test is going fine and it turns red when a test fails in eclipse.

Answer : A

Explanation

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

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

Q 5 - Which of the following method of TestCase class sets up the fixture, for example, open a network connection?

A - void setTestName()

B - void setUp()

C - void setUpFixture()

D - void setTestCase()

Answer : B

Explanation

void setUp() method sets up 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 - Which of the following method of TestSuite class returns the name of the suite?

A - String getNameOfTestSuite()

B - String getTestName()

C - String getName()

D - String getTestSuite()

Answer : C

Explanation

String getName() method returns the name of the suite.

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 - Parameterized tests allow developer to run the same test over and over again using same values.

A - true

B - false

Answer : B

Explanation

Parameterized tests allow developer to run the same test over and over again using different values.

Q 10 - Eclipse supports JUnit integration using its plugin.

A - true

B - false

Answer : A

Explanation

Eclipse supports JUnit integration using its JUnit plugin.

junit_questions_answers.htm
Advertisements