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 runs test cases significantly faster than human resources. Test cases are executed by using automation tool so less tester are required in automation testing.

Q 2 - Which of the following class contains methods to collect the results of executing a test case?

A - Assert

B - TestCase

C - TestResult

D - TestSuite

Answer : C

Explanation

TestResult class contains methods to collect the results of executing a test case.

Q 3 - Which of the following annotation causes that method run once after all tests have finished?

A - @Test

B - @After

C - @BeforeClass

D - @AfterClass

Answer : D

Explanation

Annotating a public static void method with @AfterClass cause that method run after all tests have finished. This can be used to perform clean-up activities.

Answer : B

Explanation

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

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 informs the result that a test will be started?

A - void startTest(Test test)

B - void start(Test test)

C - void execute(Test test)

D - void executeTest(Test test)

Answer : A

Explanation

void startTest(Test test) method informs the result that a test will be started.

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