Hi Wichert,<br><br>I don&#39;t understand why you would unittest a View. Could you give some examples of use case? I do understand the idea of `test things in isolation` but I don&#39;t understand what `things in a view` would you like to `test in isolation`<br>
<br>I mean, if you have some methods in a View, but this methods doesn&#39;t need the request instance at all (that seems from the tests examples you posted), why don&#39;t write that methods in the Model or in some Utility and write unittest for those <br>

<br>My apologies for give you more questions instead of answers... :)<br><br>Best Regards<br><br><div class="gmail_quote">On Wed, Apr 8, 2009 at 10:56 AM, Wichert Akkerman <span dir="ltr">&lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">No. In a unittest nothing happens automatically. That&#39;s the whole point<br>
of unittests: you want to test things in isolation.<br>
<font color="#888888"><br>
Wichert.<br>
</font><div><div></div><div><br>
<br>
Previously Paul Wilson wrote:<br>
&gt; Silly question, but has your view been grokked prior to calling its constructor?<br>
&gt;<br>
&gt; 2009/4/8 Wichert Akkerman &lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;:<br>
&gt; &gt; I think you misunderstand me. I want to unittest utility methods in my<br>
&gt; &gt; View class. I do not want to write an integration or functional test.<br>
&gt; &gt;<br>
&gt; &gt; Wichert.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Previously Vanderson Mota dos Santos wrote:<br>
&gt; &gt;&gt; You should use an integration/funtional layer in this test.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The name is not really an unit test. It is an acceptance test.<br>
&gt; &gt;&gt; You can do it in 3 ways:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; 1) Test directly in the View class API, instantiating it with the<br>
&gt; &gt;&gt; TestRequest class as parameter. This is called &quot;Under the skin&quot;(<br>
&gt; &gt;&gt; <a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/06/08/146233.aspx" target="_blank">http://codebetter.com/blogs/jeremy.miller/archive/2006/06/08/146233.aspx</a>)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; 2) User the zopetestbrowser - Best option if your view doesn&#39;t have any<br>
&gt; &gt;&gt; javascript and you don&#39;t need a browser or an &quot;Your Application&quot; instance up<br>
&gt; &gt;&gt; and running to run the test.<br>
&gt; &gt;&gt; Here you will need to use TestRequest as well.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; 3) Use selenium. But you will need to put an application instance running in<br>
&gt; &gt;&gt; order to run your tests.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; good testing!<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; 2009/4/8 Wichert Akkerman &lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt; How can you unittest a view? Trying to instantiate a view in a testcase<br>
&gt; &gt;&gt; &gt; fails when the constructor tries to access self.__view_name__ and<br>
&gt; &gt;&gt; &gt; self.module_info.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Wichert.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; --<br>
&gt; &gt;&gt; &gt; Wichert Akkerman &lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;    It is simple to make things.<br>
&gt; &gt;&gt; &gt; <a href="http://www.wiggy.net/" target="_blank">http://www.wiggy.net/</a>                   It is hard to make things simple.<br>
&gt; &gt;&gt; &gt; _______________________________________________<br>
&gt; &gt;&gt; &gt; Grok-dev mailing list<br>
&gt; &gt;&gt; &gt; <a href="mailto:Grok-dev@zope.org" target="_blank">Grok-dev@zope.org</a><br>
&gt; &gt;&gt; &gt; <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; --<br>
&gt; &gt;&gt; Vanderson Mota dos Santos<br>
&gt; &gt;<br>
&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; Grok-dev mailing list<br>
&gt; &gt;&gt; <a href="mailto:Grok-dev@zope.org" target="_blank">Grok-dev@zope.org</a><br>
&gt; &gt;&gt; <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Wichert Akkerman &lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;    It is simple to make things.<br>
&gt; &gt; <a href="http://www.wiggy.net/" target="_blank">http://www.wiggy.net/</a>                   It is hard to make things simple.<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Grok-dev mailing list<br>
&gt; &gt; <a href="mailto:Grok-dev@zope.org" target="_blank">Grok-dev@zope.org</a><br>
&gt; &gt; <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
&gt; &gt;<br>
&gt; _______________________________________________<br>
&gt; Grok-dev mailing list<br>
&gt; <a href="mailto:Grok-dev@zope.org" target="_blank">Grok-dev@zope.org</a><br>
&gt; <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
<br>
</div></div>--<br>
<div><div></div><div>Wichert Akkerman &lt;<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>&gt;    It is simple to make things.<br>
<a href="http://www.wiggy.net/" target="_blank">http://www.wiggy.net/</a>                   It is hard to make things simple.<br>
_______________________________________________<br>
Grok-dev mailing list<br>
<a href="mailto:Grok-dev@zope.org" target="_blank">Grok-dev@zope.org</a><br>
<a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar" target="_blank">www.revolucionesweb.com.ar</a><br><a href="http://www.linkedin.com/in/svidela" target="_blank">http://www.linkedin.com/in/svidela</a><br>

<br>Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el pensamiento que se hace corazón resplandece con la palabra sencilla y humilde que l@s tod@s somos.<br>