I am currently going through http://www.railstutorial.org/
It uses Rspec along with the TDD approach. I understand that writing a lot of tests can help you avoid mistakes as your application becomes more complex, but I don’t understand why you write tests for simple things like having a page name. It seems that you end up writing as many tests as the actual code.
Is it better in the long run, or is it too complicated?
It seems you have finished writing as many tests as the actual code.
, , . , , , , -, , , .
, , . , , ( ).
, , , , TDD - , , , .
AgileData.org , :
TDD - , . , , .
, .
, , , , . , (, , ) , , .
, N 2 , . , , , , .
:
if (@user.posts.count > @limit.posts) # Branch 1 flash.now[:error] = "You have posted too many times today." elsif (@user.suspended?) # Branch 2 flash.now[:error] = "Your account is suspended. You cannot post." else if (@post.special? and !@user.can.post_special?) # Branch 3 flash[:warning] = "You cannot create special posts." @post.special = false # else # Branch 4 # Not branching also has to be tested end if (@user.recently_created?) # Branch 5 @post.newbie = true # else # Branch 6 end # Branch 7 end unless (flash[:error]) @post.save! end
, , , . , . , , factory , , .
- . , , , , , , , .
, , -, , , -. , - .
-, , , .
, UI. , , , (, ) .
MVC, ui , .
, !! , !
It seems that you end up writing as many tests as actual code
.
, , TDD. , - ", ". , , , , , , .
, , , . , , TDD BDD. , , , . , , TDD, .
TDD , . , , , , , , .
, , , , , , , .
, . , .
Throughout the product life cycle , it’s easier to do maintenance work because your test suite will quickly tell you that changes to the code didn’t break anything.
Source: https://habr.com/ru/post/1756017/More articles:Moving variables in Prolog - variablesSubmit XHTML via Jabber using xmpppy - pythonMPMoviePlayerViewController problem after movie ending - iphoneWhat is the fastest way to generate a random sequence from a list of data? - c ++How to combine 2 Rails models in one place? - ruby | fooobar.comWays and best practices for connecting to SQL - c #Просмотреть проблему сдвига с помощью UIImagePickerController с источником данных как UIImagePickerControllerSourceTypeCamera - iphoneBest practice for displaying modal view above UISplitViewController - iphoneI can not understand this leak - memory-leaksProblems with tags and file verification in cvs (Sticky tags) - svnAll Articles