package com.seleniumtests.tests;

import static com.seleniumtests.core.CustomAssertion.*;
import com.seleniumtests.core.SeleniumTestPlan;
import static org.hamcrest.CoreMatchers.*;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.testng.annotations.Test;

/**
 * Using Matchers
 */
public class RetryTest2 extends SeleniumTestPlan {

    /**
     * Will not retry as test would never fail
     */
	@Test(groups="retryTest2", description = "Will retry failed assertions in this test")
	public void retryFailedTest() {
        assertThat("1 is always equal to 1", 1==1);  // This won't fail
        assertThat("1 can not be equal to 2", 1, is(2));
        assertThat("2 is always equal to 2", 2, equalTo(2));   // This won't fail
        assertThat("2 is always equal to 2", 2, is(equalTo(2)));   // Same as previous statement
        assertThat("2 can not be equal to 3", 2, is(3));
        MatcherAssert.assertThat("Hello", allOf(equalTo("Hello1"), equalTo("Hello")));
	}
}

package com.seleniumtests.tests;

import static com.seleniumtests.core.CustomAssertion.*;
import com.seleniumtests.core.SeleniumTestPlan;
import static org.hamcrest.CoreMatchers.*;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.testng.annotations.Test;

import java.util.Arrays;

/**
 * Using Matchers
 */
public class RetryTest2 extends SeleniumTestPlan {

    /**
     * Will not retry as test would never fail
     */
	@Test(groups="retryTest2", description = "Will retry failed assertions in this test")
	public void retryFailedTest() {
        assertThat("1 is always equal to 1", 1==1);  // This won't fail
        assertThat("1 can not be equal to 2", 1, is(2));
        assertThat("2 is always equal to 2", 2, equalTo(2));   // This won't fail
        assertThat("2 is always equal to 2", 2, is(equalTo(2)));   // Same as previous statement
        assertThat("2 can not be equal to 3", 2, is(3));
        assertThat("Hello", is(allOf(equalTo("Hello"), containsString("selenium"), startsWith("YouTube"), endsWith("Tellurium")))); // This fails
        assertThat("Hello", is(not(allOf(equalTo("Hello"), containsString("selenium"), startsWith("YouTube"), endsWith("Tellurium"))))); // Negative condition hence succeeds
        assertThat("Hello", is(allOf(equalTo("Hello"), containsString("Hello"), startsWith("Hello"), endsWith("Hello"))));
        assertThat("Hello", is(anyOf(equalTo("Hello1"), is("Hello2"), containsString("ell1"), startsWith("1Hell"), endsWith("llo123")))); // This fails

    }

}

add hamcrest test