Hola!

I'm new to Rails (it's my 2nd day reading the *Agile development with Rails
*book) and I'm kinda confused with the tests.

So let me get this straight: With* unit* testing, we see if our model is
working as it should (as our app's specifications demands) and Rails
provides us with all the unit testing features just to make our lifes
easier, so we don't have to manually enter values to see if they're
accepted or not. Is that right? And we're doing these tests to save
ourself from future work for fixing bugs in our code etc. With unit testing
we can pre-emptively fix our code's possible bugs, right from the beggining.

Unit testing seems clear, but Functional testing is a little confusing to
me: Why are we doing this? Where does it helps us? I know that we're
testing for example if there are certain elements in our rendered views,
for example: assert_select '#columns #side a', minimum: 4 but how could we
*not* have these elements in our views? Why are these kinds of test useful
and not just extra-code to write? To me it seems more like a
security-measure (checking if certain links appear on a page) more than a
test to see if something is wrong. However, judging from the file names,
functional testing is about the controller, right?

Thanks in advance :)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/NSDDihb48IYJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 16, 2012 at 9:32 pm

    On 16 January 2012 21:19, Agis A. wrote:
    Hola!

    I'm new to Rails (it's my 2nd day reading the Agile development with Rails
    book) and I'm kinda confused with the tests.

    So let me get this straight: With unit testing, we see if our model is
    working as it should (as our app's specifications demands) and Rails
    provides us with all the unit testing features just to make our lifes
    easier, so we don't have to manually enter values to see if they're accepted
    or not.  Is that right? And we're doing these tests to save ourself from
    future work for fixing bugs in our code etc. With unit testing we can
    pre-emptively fix our code's possible bugs, right from the beggining.

    Unit testing seems clear, but Functional testing is a little confusing to
    me: Why are we doing this? Where does it helps us? I know that we're testing
    for example if there are certain elements in our rendered views, for
    example:  assert_select '#columns #side a', minimum: 4 but how could we
    *not* have these elements in our views?
    It may seem obvious to you that the views are basically all right
    because you can see that they are when you run the s/w. However,
    perhaps there are a few conditions that change the details of what
    appears on the page, maybe you view the page as a normal user and as
    an admin, or perhaps with a different value of some field in the
    database the view changes some detail. No problem, just try each of
    these conditions and check it is ok. You can easily do this each time
    you update the website.

    Now add another 50 different pages ( a number of different controllers
    and the different views for that controller). Each of those will have
    a number of things you need to check you have not accidentally messed
    up when you release a new version of the site. To manually check that
    all the views still operate correctly becomes virtually impossible.

    With automated testing you can be reasonably sure that you have not
    accidentally messed something up and will allow you to sleep soundly
    in your bed at night.

    Colin
    Why are these kinds of test useful
    and not just extra-code to write? To me it seems more like a
    security-measure (checking if certain links appear on a page) more than a
    test to see if something is wrong. However, judging from the file names,
    functional testing is about the controller, right?
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Agis A. at Jan 16, 2012 at 9:50 pm
    I think I get it now: We 're just making sure that our views has everything
    it should in it's place (links, html elements etc) even after some new
    features we may add to our site (permission levels, authentication etc)?

    However I think that in the book it isn't explained in a clear way:
    *The unit testing of models that we did previously seemed straightforward
    enough. We called a method and compared what it returned against what
    we expected it to return. But now we are dealing with a server that
    processes
    requests and a user viewing responses in a browser. What we will need is
    functional tests that verify that the model, view, and controller work well
    together. Never fear, Rails makes this easy too.*

    It just states that we'll verify that the model, view and controller work
    well together. But as I see it, functional test is all about the controller
    and the view since *it checks for elements that appear on the view to see
    if the controller is functioning properly*, isn't that right?

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dIO_zNdPMZMJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 16, 2012 at 9:59 pm

    On 16 January 2012 21:49, Agis A. wrote:
    I think I get it now: We 're just making sure that our views has everything
    it should in it's place (links, html elements etc) even after some new
    features we may add to our site (permission levels, authentication etc)?

    However I think that in the book it isn't explained in a clear way:
    The unit testing of models that we did previously seemed straightforward
    enough. We called a method and compared what it returned against what
    we expected it to return. But now we are dealing with a server that
    processes
    requests and a user viewing responses in a browser. What we will need is
    functional tests that verify that the model, view, and controller work
    well
    together. Never fear, Rails makes this easy too.

    It just states that we'll verify that the model, view and controller work
    well together. But as I see it, functional test is all about the controller
    and the view since it checks for elements that appear on the view to see if
    the controller is functioning properly, isn't that right?
    It is also checking that the controller is calling appropriate model
    methods. That may be what it means. But mostly it is about controller
    and views, yes. It is not only checking that the correct data appears
    on the view, but also checking that the correct view is shown in the
    first place.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Agis A. at Jan 16, 2012 at 10:01 pm
    Thanks a bunch Colin!

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/gsXh5l5PHuIJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Nopik at Jan 17, 2012 at 7:54 am
    While unit testing tests each element separately, functional tests are
    aiming
    at testing system as a whole. I.e. unit testing do not check how
    elements work
    together.

    Moreover, over the course of project code changes. So, new bugs are
    introduced, too.
    Things which seem impossible at the moment ('we always have these
    elements in our views')
    after code changes are not so impossible anymore ;) This is especially
    true when new
    coder joins the team and do not know previous assumptions.
    On Jan 16, 10:19 pm, "Agis A." wrote:
    Hola!

    I'm new to Rails (it's my 2nd day reading the *Agile development with Rails
    *book) and I'm kinda confused with the tests.

    So let me get this straight: With* unit* testing, we see if our model is
    working as it should (as our app's specifications demands) and Rails
    provides us with all the unit testing features just to make our lifes
    easier, so we don't have to manually enter values to see if they're
    accepted or not.  Is that right? And we're doing these tests to save
    ourself from future work for fixing bugs in our code etc. With unit testing
    we can pre-emptively fix our code's possible bugs, right from the beggining.

    Unit testing seems clear, but Functional testing is a little confusing to
    me: Why are we doing this? Where does it helps us? I know that we're
    testing for example if there are certain elements in our rendered views,
    for example:  assert_select '#columns #side a', minimum: 4 but how could we
    *not* have these elements in our views? Why are these kinds of test useful
    and not just extra-code to write? To me it seems more like a
    security-measure (checking if certain links appear on a page) more than a
    test to see if something is wrong. However, judging from the file names,
    functional testing is about the controller, right?

    Thanks in advance :)
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 16, '12 at 9:19p
activeJan 17, '12 at 7:54a
posts6
users3
websiterubyonrails.org
irc#RubyOnRails

3 users in discussion

Agis A.: 3 posts Colin Law: 2 posts Nopik: 1 post

People

Translate

site design / logo © 2022 Grokbase