Reputation: 39
How is this possible Thanks for your help
I am on Intellij Community 2022 and I cant believe this Assert is failing.
Assert.assertTrue(new String("ss").equals("ss")) -- this fails Assert.assertTrue(new String("ss").matches("ss")) -- this fails
Upvotes: 0
Views: 555
Reputation: 339502
Assertions
, not Assert
No Assert
class in JUnit Jupiter.
Use Assertions
class.
org.junit.jupiter.api.Assertions.assertTrue( new String( "ss" ).equals( "ss" ) );
Tests passed: 1 of 1
For less typing, use static import.
package work.basil.example.squarematrix;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class SquareMatrixTest
{
@Test
void report ( )
{
assertTrue( new String( "ss" ).equals( "ss" ) );
}
}
Upvotes: 3
Reputation: 603
For compare to String expressions you have to use assertEqual function. Usage:
assertEqual(String1, String2);
Upvotes: 1