JUnit Mock Test


Advertisements

This section presents you various set of Mock Tests related to JUnit Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

JUnit Mock Test IV

Q 1 - @RunWith and @Suite annotation are used to run the suite test.

A - false

B - true

Answer : B

Explanation

Both @RunWith and @Suite annotation are used to run the suite test.

Q 2 - A test method annotated with @Ignore will not be executed.

A - false

B - true

Answer : B

Explanation

A test method annotated with @Ignore will not be executed.

Q 3 - 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 4 - @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 5 - @Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.

A - true

B - false

Answer : A

Explanation

@Test annotation along with expected attribute can be used to test the code whether code throws desired exception or not.

Q 6 - Parameterized tests allow developer to run the same test over and over again using same values.

A - true

B - false

Answer : B

Explanation

Parameterized tests allow developer to run the same test over and over again using different values.

Q 7 - Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

A - true

B - false

Answer : A

Explanation

Annotate test class with @RunWith(Parameterized.class) to create a parameterized test case.

Q 8 - 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 9 - Testing is the testing of single entity (class or method).

A - true

B - false

Answer : B

Explanation

Unit Testing is the testing of single entity (class or method). Testing is the process of checking the functionality of the application whether it is working as per requirements.

Q 10 - 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 11 - Automated Test cases are executed by using automation tool so less tester are required in automation testing.

A - true

B - false

Answer : A

Explanation

Automated Test cases are executed by using automation tool so less tester are required in automation testing.

Q 12 - JUnit is a proprietory framework.

A - true

B - false

Answer : B

Explanation

JUnit is an open source framework.

Q 13 - 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 14 - JUnit provides Assertions for testing expected results.

A - true

B - false

Answer : A

Explanation

JUnit provides Assertions for testing expected results.

Q 15 - JUnit provides Test runners for running tests.

A - true

B - false

Answer : A

Explanation

JUnit provides Test runners for running tests.

Q 16 - 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.

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

A - true

B - false

Answer : A

Explanation

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

Q 18 - 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.

Q 19 - Eclipse supports JUnit integration using its plugin.

A - true

B - false

Answer : A

Explanation

Eclipse supports JUnit integration using its JUnit plugin.

Q 20 - Fixture includes setUp() method which runs before every test invocation.

A - true

B - false

Answer : A

Explanation

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

Q 21 - 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.

Q 22 - Fixture includes tearDown() method which runs after every test method.

A - true

B - false

Answer : A

Explanation

Fixture includes tearDown() method which runs after every test method.

Q 23 - 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.

Q 24 - Assert contains a set of assert methods.

A - true

B - false

Answer : A

Explanation

Assert contains a set of assert methods.

Q 25 - 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.

Answer Sheet

Question Number Answer Key
1 B
2 B
3 B
4 B
5 A
6 B
7 A
8 A
9 B
10 A
11 A
12 B
13 A
14 A
15 A
16 A
17 A
18 B
19 A
20 A
21 B
22 A
23 B
24 A
25 A
junit_questions_answers.htm
Advertisements