0
0
JUnittesting~10 mins

assertNotEquals in JUnit - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assert that two values are not equal.

JUnit
[1](5, 3);
Drag options to blanks, or click blank then click option'
AassertNot
BassertNotEquals
CassertEquals
DassertDifferent
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertEquals instead of assertNotEquals
Misspelling the method name
2fill in blank
medium

Complete the code to assert that two strings are not equal.

JUnit
[1]("hello", "world");
Drag options to blanks, or click blank then click option'
AassertNotEquals
BassertEquals
CassertSame
DassertNull
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertEquals which expects equality
Using assertSame which checks object identity
3fill in blank
hard

Fix the error in the assertion method to check values are not equal.

JUnit
[1](10, 20);
Drag options to blanks, or click blank then click option'
AassertNotEquals
BassertTrue
CassertEquals
DassertFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertEquals when values are different
Confusing assertTrue and assertFalse for equality checks
4fill in blank
hard

Fill both blanks to assert two objects are not equal with a message.

JUnit
[1]("Objects should differ", obj1, [2]);
Drag options to blanks, or click blank then click option'
AassertNot
BassertEquals
Cobj2
DassertNotEquals
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertEquals instead of assertNotEquals
Passing the wrong object as the second argument
5fill in blank
hard

Fill all three blanks to assert two integers are not equal with a custom failure message.

JUnit
[1]("Values must not be equal", [2], [3]);
Drag options to blanks, or click blank then click option'
AassertEquals
B5
C10
DassertNotEquals
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertEquals which expects equality
Using the same integer values causing test failure