Search Header Logo

JUnit Asserts & Annotations

Authored by Luis Mendoza

Others

12th Grade

JUnit Asserts & Annotations
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of JUnit Asserts?

To slow down the testing process

To verify the expected behavior of the code being tested.

To confuse the developers

To provide entertainment

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What annotation is used to indicate that a method is a test method in JUnit?

@Method

@Test

@TestMethod

@JUnitTest

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you check if two objects are equal in JUnit?

assertTrue(expectedObject.equals(actualObject))

assertEquals(expectedObject, actualObject)

assertSame(expectedObject, actualObject)

assertNotEquals(expectedObject, actualObject)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the use of @Before annotation in JUnit?

It is used to run a method before each test method in the class.

It is used to run a method after each test method in the class.

It is used to skip a test method in the class.

It is used to define the order of test methods execution in the class.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between assertEquals and assertSame in JUnit.

assertEquals is used to compare values, assertSame is used to compare references.

assertEquals is used for arrays, assertSame is used for objects.

assertEquals compares references, assertSame compares values.

assertEquals is used for strings, assertSame is used for integers.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the significance of @After annotation in JUnit?

It is used to define the order of test methods execution in the class.

It is used to skip a test method in the class.

It is used to run a method before each test method in the class.

It is used to run a method after each test method in the class.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you ignore a test method in JUnit?

excludeTest

@Ignore

@IgnoreMethod

skipTest

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?