title: Spring MVC: How to unit test Model's attribute from a controller method that returns String?
body: <p>For example,</p>
  
  <pre><code>package com.spring.app;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  /**
   * Handles requests for the application home page.
   */
  @Controller
  public class HomeController {
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String home(final Model model) {
          model.addAttribute("msg", "SUCCESS");
          return "hello";
      }
  
  }
  </code></pre>
  
  <p>I want to test <code>model</code>'s attribute and its value from <code>home()</code> using JUnit. I can change return type to <code>ModelAndView</code> to make it possible, but I'd like to use <code>String</code> because it is simpler. It's not must though.</p>
  
  <p>Is there anyway to check <code>model</code> without changing <code>home()</code>'s return type? Or it can't be helped?</p>