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

Manual testing is less reliable as tests may not be performed with precision each time because of human errors. No programming can be done to write sophisticated tests which fetch hidden information.

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 before any of the test methods in the class?

A - @Test

B - @Before

C - @BeforeClass

D - @AfterClass

Answer : C

Explanation

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

Answer : A

Explanation

void assertEquals(boolean expected, boolean actual) checks that two primitives/Objects are equal.

Q 5 - Which of the following method of TestResult class informs the result that a test was completed?

A - void showResult(Test test)

B - void getResult(Test test)

C - void endTest(Test test)

D - void startTest(Test test)

Answer : C

Explanation

void endTest(Test test) method informs the result that a test was completed.

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 @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 - 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 - 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 - TestCase contains a test case and defines the fixture to run multiple tests.

A - true

B - false

Answer : A

Explanation

TestCase contains a test case and defines the fixture to run multiple tests.


junit_questions_answers.htm

Advertisements