title: Assert an object is a specific type
body: <p>Is it possible in JUnit to assert an object is an instance of a class? For various reasons I have an object in my test that I want to check the type of. Is it a type of Object1 or a type of Object2?</p>
  
  <p>Currently I have:</p>
  
  <pre><code>assertTrue(myObject instanceof Object1);
  assertTrue(myObject instanceof Object2);
  </code></pre>
  
  <p>This works but I was wondering if there is a more expressive way of doing this.</p>
  
  <p>For example something like:</p>
  
  <pre><code>assertObjectIsClass(myObject, Object1);
  </code></pre>
  
  <p>I could do this:</p>
  
  <pre><code>assertEquals(myObject.class, Object1.getClass());
  </code></pre>
  
  <p>Is there a specific assert method that allows me to test a type of an object in a more elegant, fluid manner?</p>