[Grok-dev] How does one unittest a view?

Santiago Videla santiago.videla at gmail.com
Wed Apr 8 10:21:18 EDT 2009


Hi Wichert,

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`

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

My apologies for give you more questions instead of answers... :)

Best Regards

On Wed, Apr 8, 2009 at 10:56 AM, Wichert Akkerman <wichert at wiggy.net> wrote:

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



-- 
Santiago Videla
www.revolucionesweb.com.ar
http://www.linkedin.com/in/svidela

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 at s tod at s somos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20090408/38b56efd/attachment.html 


More information about the Grok-dev mailing list