<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: How to Unit Test Spring MVC Controller	</title>
	<atom:link href="https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 17:19:23 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>
		By: Choon-Chern Lim		</title>
		<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-32</link>

		<dc:creator><![CDATA[Choon-Chern Lim]]></dc:creator>
		<pubDate>Sun, 30 Mar 2014 23:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://myshittycode.com/?p=170#comment-32</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-31&quot;&gt;Sandeep&lt;/a&gt;.

You can use &lt;code&gt;jsonPath(..)&lt;/code&gt; from &lt;a href=&quot;http://docs.spring.io/spring/docs/3.2.0.RC1/api/org/springframework/test/web/servlet/result/MockMvcResultMatchers.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener ugc&quot;&gt;MockMvcResultMatchers&lt;/a&gt; to get all the persons. The second argument of &lt;code&gt;jsonPath(..)&lt;/code&gt; takes a Hamcrest matcher. Now, you can use something like &lt;code&gt;hasItems(..)&lt;/code&gt; from &lt;a href=&quot;http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener ugc&quot;&gt;Matchers&lt;/a&gt; to perform your assertions.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-31">Sandeep</a>.</p>
<p>You can use <code>jsonPath(..)</code> from <a href="http://docs.spring.io/spring/docs/3.2.0.RC1/api/org/springframework/test/web/servlet/result/MockMvcResultMatchers.html" target="_blank" rel="nofollow noopener ugc">MockMvcResultMatchers</a> to get all the persons. The second argument of <code>jsonPath(..)</code> takes a Hamcrest matcher. Now, you can use something like <code>hasItems(..)</code> from <a href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html" target="_blank" rel="nofollow noopener ugc">Matchers</a> to perform your assertions.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sandeep		</title>
		<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-31</link>

		<dc:creator><![CDATA[Sandeep]]></dc:creator>
		<pubDate>Sun, 30 Mar 2014 23:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://myshittycode.com/?p=170#comment-31</guid>

					<description><![CDATA[In case personService.getPerson() returns List, how will you address this Mock test?]]></description>
			<content:encoded><![CDATA[<p>In case personService.getPerson() returns List, how will you address this Mock test?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jakub		</title>
		<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-30</link>

		<dc:creator><![CDATA[Jakub]]></dc:creator>
		<pubDate>Sun, 23 Mar 2014 07:34:46 +0000</pubDate>
		<guid isPermaLink="false">http://myshittycode.com/?p=170#comment-30</guid>

					<description><![CDATA[It works. Thanks.]]></description>
			<content:encoded><![CDATA[<p>It works. Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Choon-Chern Lim		</title>
		<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-29</link>

		<dc:creator><![CDATA[Choon-Chern Lim]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 12:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://myshittycode.com/?p=170#comment-29</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-28&quot;&gt;Jakub&lt;/a&gt;.

In that case, you can call &lt;code&gt;when(...).thenCallRealMethod();&lt;/code&gt; on non-mocked dependencies. See this post for more info: http://myshittycode.com/2014/03/13/mockito-effective-partial-mocking/]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-28">Jakub</a>.</p>
<p>In that case, you can call <code>when(...).thenCallRealMethod();</code> on non-mocked dependencies. See this post for more info: <a href="http://myshittycode.com/2014/03/13/mockito-effective-partial-mocking/" rel="ugc">http://myshittycode.com/2014/03/13/mockito-effective-partial-mocking/</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jakub		</title>
		<link>https://myshittycode.com/2013/10/23/how-to-unit-test-spring-mvc-controller/#comment-28</link>

		<dc:creator><![CDATA[Jakub]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 10:51:54 +0000</pubDate>
		<guid isPermaLink="false">http://myshittycode.com/?p=170#comment-28</guid>

					<description><![CDATA[Hi,

What in case when controller has more dependencies  except that one which is mocked? How to inject them into tested controller?

Regards,
Jakub]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>What in case when controller has more dependencies  except that one which is mocked? How to inject them into tested controller?</p>
<p>Regards,<br />
Jakub</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching 52/62 queries in 0.029 seconds using Disk

Served from: myshittycode.com @ 2026-03-01 23:30:32 by W3 Total Cache
-->