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

Since test cases are executed by human resources so it is very slow and tedious and as test cases need to be executed manually so more testers are required in manual testing.

Answer : C

Explanation

Fixture is a fixed state of a set of objects used as a baseline for running tests. The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable.

Q 3 - Which of the following annotation causes that method to be run before each Test method?

A - @Test

B - @Before

C - @After

D - @BeforeClass

Answer : B

Explanation

Annotating a public void method with @Before causes that method to be run before each Test method.

Answer : C

Explanation

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

Answer : B

Explanation

void addFailure(Test test, AssertionFailedError t) method adds a failure to the list of failures.

Q 6 - Which of the following method of TestResult class returns an Enumeration for the errors?

A - Enumeration<Object> errors()

B - Enumeration<TestFailure> errors()

C - Enumeration<TestFailure> getErrors()

D - Enumeration<Object> getErrors()

Answer : C

Explanation

Enumeration<TestFailure> errors() method returns an Enumeration for the errors.

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 - Which of the following class is used to run test cases?

A - JUnitCore

B - TestCase

C - TestSuite

D - TestResult

Answer : A

Explanation

The test cases are executed using JUnitCore class.

Q 9 - Testing is the process of checking the functionality of the application whether it is working as per requirements.

A - true

B - false

Answer : A

Explanation

Testing is the process of checking the functionality of the application whether it is working as per requirements.

Q 10 - Unit Tests are written after the code during development in order to help coders test the code.

A - true

B - false

Answer : B

Explanation

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

junit_questions_answers.htm
Advertisements