{"id":4501,"date":"2011-11-30T16:48:52","date_gmt":"2011-11-30T11:18:52","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=4501"},"modified":"2022-01-12T18:58:17","modified_gmt":"2022-01-12T13:28:17","slug":"grails-productivity-enhancer-the-unsung-hero-grails-interactive-mode","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/grails-productivity-enhancer-the-unsung-hero-grails-interactive-mode\/","title":{"rendered":"Grails productivity enhancer. The unsung hero &#8216;grails interactive mode&#8217;"},"content":{"rendered":"<p>Of late, I have been thinking about the popularity of <a title=\"Grails Developers and Architects\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">grails interactive mode amongst developers<\/a>. I found that though most of us are aware of this mode but we don&#8217;t use it as often, as it should be.<\/p>\n<p><strong>Where should I use grails &#8211;interactive mode while developing in grails?<\/strong><br \/>\nThe answer may vary from person to person and the level of expertise. For me, I found it amazing while running my tests and creating artifacts.<\/p>\n<p>I shall describe the advantages that I found with interactive mode while running Unit Tests. Let us take an example here:<\/p>\n<p>I have a class called PersonUtil which needs to be unit tested. I write a PersonUtilTests class for testing its functionality. In order to run this particular unit test, I can use the following command:<\/p>\n<p>grails test-app unit: PersonUtilTests<\/p>\n<p>This takes approximately 20 secs on an average to run on my machine with a decent configuration.<\/p>\n<p>Alternatively, We can run it in interactive mode. What we need to do is<\/p>\n<p> grails &#8211;interactive<\/p>\n<p>This shall bring the grails infrastructure up and make it just ready to run commands. It takes around 5 seconds.<\/p>\n<p>Welcome to Grails 1.3.7 &#8211; http:\/\/grails.org\/<br \/>\nLicensed under Apache Standard License 2.0<br \/>\nGrails home is set to: \/opt\/grails<\/p>\n<p>Base Directory: \/home\/farid\/grailsApplications\/survey-app\/ErServices<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nInteractive mode ready. Enter a Grails command or type &#8220;exit&#8221; to quit interactive mode (hit ENTER to run the last command):<\/p>\n<p>Now, to test the app I can use the following command:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nCommand TestApp completed in 2461ms<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nInteractive mode ready. Enter a Grails command or type &#8220;exit&#8221; to quit interactive mode (hit ENTER to run the last command):<br \/>\ntest-app unit: PersonUtilTests<\/p>\n<p>It took 15 seconds to run this for first time.<br \/>\nFor subsequent runs, it took 2-4 seconds. Which is a clear advantage of 16 seconds for every run. These 16 seconds are no less than gem when you are in your &#8220;flow-state&#8221;( in concentration mode).<\/p>\n<p>While development, we make frequent changes to our code and therefore we need to run our unit tests multiple times. Every time I make a change and re run my unit test it takes 20 seconds through conventional grails test-app whereas it takes 3-4 seconds through interactive mode.<\/p>\n<p>Earlier, I used to get frustrated while waiting for test cases to execute. This waiting time is one of the biggest factor that drives us from doing Test Driven Development.<\/p>\n<p>Just in case you have not tried it. Please give it a shot. Believe me, it&#8217;s worth trying, you wont be disappointed!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Of late, I have been thinking about the popularity of grails interactive mode amongst developers. I found that though most of us are aware of this mode but we don&#8217;t use it as often, as it should be. Where should I use grails &#8211;interactive mode while developing in grails? The answer may vary from person [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[7],"tags":[4840,693,694,695,452,272],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4501"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=4501"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4501\/revisions"}],"predecessor-version":[{"id":54606,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4501\/revisions\/54606"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=4501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=4501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=4501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}