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

Vanderson Mota dos Santos vanderson.mota at gmail.com
Wed Apr 8 10:06:29 EDT 2009


There is no silly questions, there is the ones that are easy or hard to
answer.

"No. In a unittest nothing happens automatically. That's the whole point
of unittests: you want to test things in isolation."

As far as i know, if you test a view, it is an acceptance testing.
Well, i guess you will have to use the integration layer to make the test
fixture easier to build.
2009/4/8 Wichert Akkerman <wichert at wiggy.net>

> 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
>



-- 
Vanderson Mota dos Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20090408/ba1834c9/attachment.html 


More information about the Grok-dev mailing list