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.

没有正确的解决方案

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top