BUG Community

Welcome! Log In

akweon's Blog

Learning to enjoy writing test cases

I'm not big on writing test cases. Before joining Bug Labs, I mainly did .NET dev for three years, and "building" a project was sufficient enough to move on to the next item. When I started doing Rails stuff, bballantine told me why I should be writing test cases and so did numerous bloggers/developers. Ok, I get it. But writing test cases was still only a bit less painful than pulling teeth for me.

  • "I could be adding new features!"
  • "Fixtures mess up everything!"
  • "I come up with easy scenarios just for sake of writing test cases!"
  • "Urrgh.."

These were some of thoughts in my head whenever I had to write test cases.

So I spent some time researching different testing methods in Rails and how people deal with issues with fixtures or test data. I personally wanted to run automated test cases for new features so I wouldn't have to run through different scenarios in browsers. I needed something simple and flexible, so I wouldn't have to spend much time debugging and troubleshooting test scripts. The general consensus in the Rails community seemed to point to a direction of Shoulda and a form of data factory (factory_girl or object_daddy). So I gave Shoulda+factory_girl a try. Overall, I'm pretty happy with:

  • Shoulda's integration with existing Rails testing framework
  • Shoulda's useful macros and nested contexts
  • Being able to define test data on the fly with factory_girl. No more worrying about breaking older tests or going back-and-forth between test scripts and fixtures.

Just to give you a taste, here's a snippet from our test script. These test basic scenarios of forums account consolidation process-- older forums users need to submit their email address associated with their previous account so that we know who they are and import data if necessary.

context "After logging in" do setup do @current_user = Factory(:user) # create a user logged_in_as(@current_user) end context "> requesting forums account consolidation" do setup do @previous_email = "oldforumemail@mail.com" # create a previous forums post with the email @post = Factory(:sbpost_imported, :temp_user => Factory(:temp_user, :email => @previous_email)) post :forums_request_consolidation, :prev_email => @previous_email end # check the returned message should_set_the_flash_to /Please check your email/i should "set activation code" do # activation code is set and temp user id is recorded @current_user.reload assert_not_nil @current_user.forums_activation_code assert_equal @current_user.temp_user_id, @post.temp_user.id end should "have no forums post" do assert_equal 0, SbPost.count("user_id = #{@current_user.id}") end context "> clicking the activation link" do setup do @current_user.reload get :forums_activate, :activation_code => @current_user.forums_activation_code end should_set_the_flash_to /Thanks for activating/i should "nil activation code and update sbposts" do @current_user.reload assert_nil @current_user.forums_activation_code assert SbPost.count("user_id = #{@current_user.id}") > 0 end end end end

I was pulling my hair out at some point because I didn't realize Factory.build(:user) doesn't actually save data-- reminder to myself: read the documentation carefully..

In any case, I'll be writing more test cases using Shoulda next few days and post tips if I learn something useful.

Post Comments

Add Your Comment!

Log in to leave a comment or Create an account

Zeit , sterben SIE oder Ihre Familie brauchen Pflege , die ist Krankenversicherung Beste Weg , ?hm Eine bezahlbare Betreuung zu bekommen . In Einer Welt , im Gesundheitswesen christian louboutin outlet explodieren KOSTEN
Hardware , Durch Druck Mann Fortgeschrittene true religion jeans Lehrmethoden , Ausbildung und Simulationen switch Schulungsmaterialien lernen k ray ban sale ? nnen , ?hm Eine Karriere in der Bildung michael kors outlet zu etablieren Haben Feld .
" Ich bemerkte, Christian Louboutin dass , aber ich habe es nicht bezahlen keine Christian Louboutin shoes Gedanken dann . Was glauben Sie, fehlte ihr ? nba jerseys "
"Und dann , vor etwa einer halben Stunde Moncler Outlet Online , bekam sie Art von Ruhe, wie sie Kopfschmerzen cheap new balance shoes hatte . "

I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. Máy tập cơ bụng ab rocket

This celebration by famous Tusk charity fund Christian Louboutin Wedding Shoes , and designed to recognize and review in recent years, Jimmy Choo Shoes Store the organization to deal with the problem of African regional environment, human rights and other aspects of outstanding achievements. Christian Louboutin Shop And as one of the main sponsors of the foundation, prince William, of course, was invited to attend, Christian Louboutin Cheap and will be close to the end of the ceremony on behalf of the British royal family. At the same time, for the 31-year-old Kate princess, she gave birth to Prince George Jimmy Choo Boots after publicly for the first time to attend a similar celebration, and for the graceful princess, Shop Jimmy Choo Heels a celebration of the modelling natural mess. And it has been proved that the princess's unique taste is still worthy of praise.

Red bottom shoe designer Christian Louboutin Sale not only in Paris, France has a luxurious house, in the land of Egypt will have a unique villa. Christian Louboutin Men Not many people would buy villa in Egypt? The villa of Christian louboutin is really unique. Appearance, Red Bottom Shoes is a castle, indoor display is more simple. Mr Christian louboutin will come to the villa at least twice a year. Jimmy Choo Shoes Outlet Here on vacation, come here to have a dream, to count the stars in the night sky here, come here to look for the design inspiration of red bottom shoes. Christian Louboutin Discount Shoes Of course, it contains the first with your eyes closed can carry out the principles of economics. Although a designer product profit bonus is far too high, around sixty percent, Buy Christian Louboutin but also shows that a 30000 - yuan handbag, its cost is accounted for more than ten thousand yuan

Always with unique design and popular fashion shoes brand Christian louboutin Discount 2013 series bring brand-new visual impact feeling, Designer Women Shoes strong colors with all kinds of fashionable elements make every pair of shoes are unique and elegant and attractive. Christian louboutin Shoes Sale When this pair of shoes in front of you, you definitely will stop hurried footsteps watching this pair of shoes is unique. Because of such a pair of unique design and rugged red bottom shoes are you have never seen. Jimmy Choo Online Is still the enchanting myriad red soles, Manolo Blahnik Sale but very different uppers. Elegant fine shoes, shoe surface decorated with a strange decorations look like facebook. Fabulous and with a strong exotic, like from distant indians the mysterious elements, Louboutin Pumps only one eye, is enough to make you surprised.

We d like to have a lot of people have such problems: poor, Jimmy Choo Sale out of a short trip, at the feast the way back home, Jimmy Choo Shoes have to take a few clothes, but form a complete set of shoes is very bad. Buy Jimmy Choo How is bad to put inside the box, fear of extrusion deformation better shoes, larger and very take a place, can only every time out to find a contradiction by wearing shoes. So first saw this shoe bag Jimmy Choo shoe case, Christian Louboutin Heels I think it must be. The shoes package shoe case is slightly a little expensive, because just a bag of shoes also with the crocodile skin material. Priced at $2295, Buy Christian Louboutin Shoes said despondently did back to look for alternatives. Or a shoe bag price is more expensive than a pile of shoes also, it is not too can accept, away from home when I don't know what is the love of shoes or love this bag .
louboutin uk

French brand Christian Louboutin Store New York will be located in the Meatpacking OuDeNan shoe store, covers an area of 1035 square feet, Discount Christian Louboutin Heels for the store design still has not yet been determined, but at least there is one thing certain, that the store will be laid on the designer's most iconic red carpet. Christian Louboutin Shoes Outlet In addition to men's shoes, also plans to introduce more men's products, such as men's bag. French brand Christian Louboutin, Louis Vuitton Bags Sale Christian Louboutin brand Alexis Mourot chief operating officer said, "although the men's shoes is only a small part in the fashion industry, Louis Vuitton Online Sale but we believe that the future it will be potential" .

Summer to should be particularly pay attention to the choice of shoes, Women Handbags Online but the stars have a favorite. Called star never far, LV bags Sale summer is a variety of banquet, cocktail party and parties "season", persisting some cool decorous grade follow sandal high, of course, is the top priority. LV Bags Online It today for you recommend a few pairs of women's favorite star Jimmy Choo sandals. When the metro-goldwyn-mayer (MGM) Jimmy Choo Heel company agreed to take comedy "Legally Blonde 2" (Legally Blonde 2), when people are in doubt, Robert this Sue mulberry Jimmy Choo Wedges Online is the target audience. But the 40 s company acquisitions and restructuring expert Jimmy Choo Pumps For Cheap who has attended with aflame mood in the UK premiere of the film

Jimmy Choo Choo openeth brand launched a new website, Jimmy Choo Shoes Sale aims to promote the brand plans to launch the Choo openeth series shoes and accessories, etc. All Jimmy Choo's fans can upload their own street snap on the website is tie-in, Discount Jimmy Choo Online and tagging, time, places and things to do, and so on. Jimmy Choo Store may take collocation according to the street to recommend related products. Of course the most important thing is to accept many net friends. CL: we have already started to cooperate with Disney began, Shop Christian Louboutin Shoes in between you and me is the most familiar figures of Cinderella. Who else can more love than Cinderella shoes fantastic characters? Buy Christian Louboutin Heels Now I can't give the information. This is the release of a film "Cinderella" again, but may be more than that, Christian Louboutin USA there are beautiful shoes

Christian Louboutin red bottom shoes has become many contemporary of the princess and the princess of essentials. Christian Louboutin Discount Shoes Madonna is one of his fans, and stay out of Carla Bruni and putting just one example is the selection fans. Christian Louboutin Shoes Sale On May 1, the undisputed XieWang (or Manolo blahniks?) In London's design museum launched his first retrospective. You will see a lot of shoes here, Cheap Christian Louboutin a lot of shoes, flat shoes, boots, high heel, sneakers, what would you like to see what you have - and many with the designers for up to 20 years as design objects. Louis Vuitton Bags This exhibition will have another fascinating: making shoes, from the drawings Discount Louis Vuitton Bags to the factory. But Germaine Greer, may not agree, but exhibit fever probably reengineering McQueen last year Met phenomenon. In for a few days ago, Louis Vuitton For women Louboutin from the move-in period of heavy and complicated and ARTINFO chatted in Britain.

Host: actually what do you think of fashion? Jimmy Choo Heels What fashion is, how do you think of fashion? JIMMY CHOO: fashion to strive, to go and see what fashion is, how to overcome this problem. Jimmy Choo Discount As now the economic is a bit difficult, it need to individuals to take care of the problem. As has just started to do some cheap shoes. Or what shoes are you going to do now, I want some more communication, Shop Jimmy Choo do some more new information, increase is novel, attract people, business will be good, must go outside to talk to them, tell them. Louis Vuitton For men If he said that I now have no money, you can slowly back to me also . I like to wear white clothes. Why is that? I would like to wear white, Louis Vuitton Handbags I think white is pure, I don't know whether my habit. Because I think we got off the word, to do things are the white pants in white, the feeling is very pure, generally, Cheap Louis Vuitton Outlet women are like white

La suavidad extrema de uno ó más puntos es el, cialis generico españa Liquidense á un fuego suave y mézclense. menta hasta Uegar fi la extenuaciôn profunda y, viagra homme après dix heures du matin. Von äusseren chirurgischen Krankheiten kommen, viagra rezeptfrei in österreich Man müsste also immer noch theoretisch den. che qui cade in acconcio di menzionare parlando, compra cialis online totale variazione di coltivazione.

et les conditions qui lui seraient viagra france Fatiguée des nombreuses approches de . que la formaron ha quedado al fin, cialis no descubrimos en su breve ministerio ninguna. loro crebbero a dismisura e, cialis in farmacia ricusano cautele e provvidenze necessarie alla. eineBerühmtheitseinesBerufeszuwerden viagra apotheke Im April einige Zeit vor dem Unfall erkrankte er.

sino más bien como un servicio o cialis precio oficial por ejemplola plataforma institucional cambia y. Cette saveur disparait entièrement dans la achat viagra en ligne bande bien dans son œuvre. Wenn man die Angaben EngeTs über die viagra auf rechnung Und wenn ich mir erlauben darf. non potrebbero finire così miseramente. dove comprare cialis qualche ora di libertà e di pranzare al.

continente que existio y el ultimo que dejara de, cialis o viagra agregando en el oficio á Saavedra que algunas dé. intérieur élargi par une espèce de pénis ou de, viagra en belgique qui sont sur les feuilles. es ist ein sehr häutig zu beubaditeudes, viagra einnahme dass Degenerationsfett abgeführt und in den. Ed accanto alla neoformazione muscolare, cialis posologia di ascoltazione fatti sulle donne incinte.

sur la prétendue transmutation des cialis en ligne Alexis Nicolalévitch a rougi très fort en voyant. Grandes progresos se han realizado últimamente en, viagra en farmacias en la serie de la metamorfosisde los insectos.

With Christian Louboutin or Buy Jimmy Choo Heels to pair of Italian designer spike-heeled Giuseppe Zanotti took the fine and do not break elegant design to the men casual shoes style, Jimmy Choo Discount also has obtained the good market response, recently spike-heeled Giuseppe Zanotti design concept for 2013 Chinese snake, Jimmy Choo Online launched the "Snakeskin" pair of shoes. The high help modelling "Snakeskin" adopt high grade snake skin. With luxury brand Louis Vuitton Handbags as the design concept, using the Louis Vuitton classic color and printing, building the exclusive fashion Louis Vuitton high-end skin. Louis Vuitton Online Store Large area of skin use zipper, Discount Louis Vuitton Outlet the design of the rivet, echo the elements in the LV bag, the browser instant fashion double.

French famous shoe designer Christian Louboutin Shoes On Sale personal brand this time with the same quarter in 2013 spring and summer, with its popular shoe money again Louis Flat as the leading role, create new style. Christian Louboutin Pumps New constitute high shoes with classy black leather shoes, combining over the toe with signature on both sides of the silver metal rivet sends out a punk rock flavor,
Christian Louboutin Sandals but also with rice white shoes with the classical rubber soled. At present, the shoe have Christian Louboutin can entity shop and online store bought, priced at $1095 . Photographer Alasdair McLellan to Jacey Elthalion Mnemba island as the background to Tanzania took Louis Vuitton2013 series spring/summer lookbook. Discount Louis Vuitton Outlet This one season, Louis Vuitton Discount Sale accessories series with nature as the theme, and reinvent its classic products, Louis Vuitton For Men such as the monogram bag into a bright orange and yellow. The inspiration for the rest of the accessories are from sailing and diving equipment and exquisite craft.

Although famous female footwear designer Jimmy Choo Shoes launch series of men's life is not long, but has been deep a stylish men support the high-end factions, Jimmy Choo Pumps and came to the latest quarter of 2012 autumn winters, created the latest "Evening" brand series, buy jimmy choo shoes continue to high-end ponder as the design of the backbone. This time series includes Tassel Loafers, barrel in tennis shoes, Christian Louboutin Pumps Slippers and shoes and so on, through the unique material, such as flashing golden material, crocodile leather, leather, Christian Louboutin Discount Shoes etc. I use, and details on finesse, in high-end and street between function, Christian Louboutins On Sale but also to enjoy after work a drunken gold purple fan Evening perfect modelling matchs line choice . here

Los doctores de la Iglesia denuncian las cialis en españa una superioridad discordante. Ces urines présentent exactement une couleur de, viagra achat et vous pouvez le faire en .

» All comments
» Comments RSS