By
using 'equalToIgnoringCase' method, you can create a matcher of string that
matches when the examined string is equal to the specified expected string,
ignoring case.
Ex
String
str = "abrakadabra";
assertThat("comparing
strings by ignoring case ", str,
equalToIgnoringCase("ABRAKADABRA"));
Find
the below working application.
TestApp.java
package com.sample.model; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringCase; import org.junit.Test; public class TestApp { @Test public void testmethod() { String str = "abrakadabra"; assertThat("comparing strings by ignoring case ", str, equalToIgnoringCase("ABRAKADABRA")); assertThat("comparing strings by ignoring case ", str, equalToIgnoringCase("ABRAKAdabra")); assertThat("comparing strings by ignoring case ", str, equalToIgnoringCase("abraKADABRA")); assertThat("comparing strings by ignoring case ", str, equalToIgnoringCase("ABRAkaDABRA")); } }
No comments:
Post a Comment