By
using ‘typeCompatibleWith’ function, you can create a matcher that matches when
the specified baseType is assignable from the examined class.
Ex
assertThat("Intger
class must be assigned to Number class", Integer.class,
typeCompatibleWith(Number.class));
TestApp.java
package com.sample.tests; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.typeCompatibleWith; import org.junit.Test; public class TestApp { @Test public void testmethod() { assertThat("Intger class must be assigned to Number class", Integer.class, typeCompatibleWith(Number.class)); } }
No comments:
Post a Comment