Forum: Ruby on Rails Lazy testing of rails applications

05c3f39db309047f28628a223a757bec?d=identicon&s=25 Hans Marmolin (marmolin)
on 2013-01-27 12:26
(Received via mailing list)
I have problem with applying a test driven development as It takes too
long
time and effort for the kind of applications that I develop as an
application developer (working alone)
However, after a while., also my applications become so complicated that
changing one part has effect on other parts, i.e correcting one bug,
often
generates new bugs.
I am therefore looking for some kind of lazy testing approach with a
scaffolding technique for generating test code, based on running each
action and method with same combination of valid in- and outdata. I
think
it would be possible to develop at least simple test in that way but I
have
not found any when googling for them.
I very simple example  would be to generate tests of the six generic
actions in each controllers according to e.g this template
test "should get index" do
  get :index
  assert_response :success
  assert_not_nil assigns(:posts)
end
Although this is a very simple test it would be better than nothing.
One could also try to analyse a log file to find the valid in and out
data
of each action and method used

Do anyone know of other attempts to do what I described here?
Do you think it is possible to develop generators that accomplish this
kind
of lazy testing ?
Would it be worthwhile do make such testings ?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2013-01-28 12:44
(Received via mailing list)
On Sunday, January 27, 2013 11:24:42 AM UTC, Hans wrote:
> it would be possible to develop at least simple test in that way but I have
> not found any when googling for them.
> I very simple example  would be to generate tests of the six generic
> actions in each controllers according to e.g this template
> test "should get index" do
>   get :index
>   assert_response :success
>   assert_not_nil assigns(:posts)
> end
>


If you use the scaffold generators then you will get those tests
generated
for you. However a test like that really doesn't go very far at all into
helping with the sorts of more complicated interactions that you are
describing. For me this is about at the same level as "it compiles"
might
be in a language like java or c++


> Although this is a very simple test it would be better than nothing.
> One could also try to analyse a log file to find the valid in and out data
> of each action and method used
>
> Do anyone know of other attempts to do what I described here?
> Do you think it is possible to develop generators that accomplish this
> kind of lazy testing ?
> Would it be worthwhile do make such testings ?
>
>
Test code is to me as important as application code - I don't think you
can
write good 'lazy' tests any more than you can write a lazy application

Fred
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2013-01-28 13:11
(Received via mailing list)
On 27 January 2013 11:24, Hans <Hans.Marmolin@klockholm.se> wrote:
> I have problem with applying a test driven development as It takes too long
> time and effort for the kind of applications that I develop as an
> application developer (working alone)

So it takes longer to do the first iteration of a simple site using
TDD.  Very likely true.

> However, after a while., also my applications become so complicated that
> changing one part has effect on other parts, i.e correcting one bug, often
> generates new bugs.

And in the long run you realise that actually it would have been
better to invest the additional effort from the start.  Also true.  So
the moral is, for the next project, do the tests from the beginning.

>   assert_not_nil assigns(:posts)
> end
> Although this is a very simple test it would be better than nothing.
> One could also try to analyse a log file to find the valid in and out data
> of each action and method used

As Fred has pointed out you can get basic tests generated by the
scaffolding but whether they are much use is debatable.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.