Question

Consider the test messageTest(see below)

  publicclassmessageTest { 
    @Test
    publicvoidtestMessageLength() {
    String message = "Test Message";

    }
}

Add Assert method to verify that text in message contains 12 characters.

Pas de solution correcte

Autres conseils

You can assert it with actual length and expected length of the String. You need to import either junit Assert or testNg Assert, in order to use it

@Test
    publicvoidtestMessageLength() {
    String message = "Test Message";
    Assert.assertEquals(message.length(), 12);
    }

String.length()

If that is what you are looking for.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top