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

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

Explanation

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

Answer : B

Explanation

void assertTrue(boolean condition) checks that a condition is true.

Q 5 - Which of the following method of TestCase class creates a default TestResult object?

A - TestResult getTestResult()

B - TestResult createResult()

C - TestResult getTestResultInstance()

D - TestResult testResult()

Answer : B

Explanation

TestResult createResult() method creates a default TestResult object.

Answer : A

Explanation

void run(TestCase test) method runs a TestCase.

Q 7 - Which of the following method of TestSuite class runs the tests and collects their result in a TestResult?

A - void execute(TestResult result)

B - void runTest(TestResult result)

C - void run(TestResult result)

D - void executeTest(TestResult result)

Answer : C

Explanation

void run(TestResult result) method runs the tests and collects their result in a TestResult.

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 - JUnit 4.0 provides Annotations to identify the test methods.

A - true

B - false

Answer : A

Explanation

JUnit 4.0 provides Annotations to identify the test methods.

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