Hi Wichert,<br><br>I don'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'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't need the request instance at all (that seems from the tests examples you posted), why don'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"><<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>></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'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>
> Silly question, but has your view been grokked prior to calling its constructor?<br>
><br>
> 2009/4/8 Wichert Akkerman <<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>>:<br>
> > I think you misunderstand me. I want to unittest utility methods in my<br>
> > View class. I do not want to write an integration or functional test.<br>
> ><br>
> > Wichert.<br>
> ><br>
> ><br>
> > Previously Vanderson Mota dos Santos wrote:<br>
> >> You should use an integration/funtional layer in this test.<br>
> >><br>
> >> The name is not really an unit test. It is an acceptance test.<br>
> >> You can do it in 3 ways:<br>
> >><br>
> >> 1) Test directly in the View class API, instantiating it with the<br>
> >> TestRequest class as parameter. This is called "Under the skin"(<br>
> >> <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>
> >><br>
> >> 2) User the zopetestbrowser - Best option if your view doesn't have any<br>
> >> javascript and you don't need a browser or an "Your Application" instance up<br>
> >> and running to run the test.<br>
> >> Here you will need to use TestRequest as well.<br>
> >><br>
> >> 3) Use selenium. But you will need to put an application instance running in<br>
> >> order to run your tests.<br>
> >><br>
> >> good testing!<br>
> >><br>
> >> 2009/4/8 Wichert Akkerman <<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>><br>
> >><br>
> >> > How can you unittest a view? Trying to instantiate a view in a testcase<br>
> >> > fails when the constructor tries to access self.__view_name__ and<br>
> >> > self.module_info.<br>
> >> ><br>
> >> > Wichert.<br>
> >> ><br>
> >> > --<br>
> >> > Wichert Akkerman <<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>> 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>
> >> ><br>
> >><br>
> >><br>
> >><br>
> >> --<br>
> >> Vanderson Mota dos Santos<br>
> ><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>
> ><br>
> ><br>
> > --<br>
> > Wichert Akkerman <<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>> 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>
> ><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>
<br>
</div></div>--<br>
<div><div></div><div>Wichert Akkerman <<a href="mailto:wichert@wiggy.net" target="_blank">wichert@wiggy.net</a>> 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>