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 tools provides JUnit integration?

A - Eclipse

B - Ant

C - Maven

D - All of the above.

Answer : D

Explanation

All of the above tools provides JUnit integration.

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.

Q 4 - Which of the following method of Assert class fails a test with no message?

A - void assertChecks(boolean pass)

B - void assertCheck(boolean pass)

C - void assert(boolean pass)

D - void fail()

Answer : D

Explanation

void fail() fails a test with no message.

Q 5 - Which of the following method of TestCase class tears down the fixture, for example, close a network connection?

A - void tearDownTestName()

B - void tearDown()

C - void tearDownFixture()

D - void tearDownTestCase()

Answer : B

Explanation

void tearDown() method tears down the fixture.

Q 6 - Which of the following method of TestResult class gets the number of detected errors?

A - int getErrors()

B - int errorCount()

C - int countErrors()

D - int getErrorCount()

Answer : B

Explanation

int errorCount() method gets the number of detected 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 - If a test class is annotated with @Ignore then none of its test methods will be executed.

A - false

B - true

Answer : B

Explanation

If a test class is annotated with @Ignore then none of its test methods will be executed.

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 - JUnit tests can be run automatically and they check their own results and provide immediate feedback.

A - true

B - false

Answer : A

Explanation

JUnit tests can be run automatically and they check their own results and provide immediate feedback.


junit_questions_answers.htm

Advertisements