It is necessary in the test to verify that a particular object has a certain type.
boolean res = (desc[2][7] instanceof Place); assertThat(res,is(true)); Something like that not to write ... Is there any method in util?
It is necessary in the test to verify that a particular object has a certain type.
boolean res = (desc[2][7] instanceof Place); assertThat(res,is(true)); Something like that not to write ... Is there any method in util?
Need to use org.hamcrest.CoreMatchers.instanceOf
Example:
import org.junit.Test; import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertThat; abstract class AbstractClass { } class ClassImp extends AbstractClass { } public class InstanceOfTest { @Test public void testInstanceOf() { final AbstractClass subClass = new ClassImp(); assertThat(subClass, instanceOf(AbstractClass.class)); } } Source: https://ru.stackoverflow.com/questions/593096/
All Articles