title: How can I compare ModelAndView objects in Junit testing?
body: <p>Currently the test shows that both objects returned are the same, but the assert fails. Is there any way to compare them?</p>
  
  <pre><code> @Test
      public void test_search() throws Exception {
          TestObject testObject= createTestObject();
  
          ModelAndView expectedReturn = new ModelAndView("example/test", "testForm", testObject);
          expectedReturn.addObject("testForm", testObject);
  
  
  
          ModelAndView actualReturn = testController.search(testObject);
  
          assertEquals("Model and View objects do not match", expectedReturn, actualReturn);
      }
  </code></pre>