Cwgordon7's blog - simpletest /taxonomy/term/5/0 en How to: Write Automated Tests for Drupal /how-to-write-automated-tests-for-drupal <p>With <a href="">an automated testing framework in core</a>, Drupal is now far along the road to a practice of <a href="">Test-driven development</a>. But there's one thing missing: a complete, in-depth, up-to-date tutorial on how to actually <strong>write</strong> these tests. Although there is the <a href="">SimpleTest Automator</a> module to help you create these tests through the user interface, it is currently imperfect and under development, so this post will be a tutorial on writing these tests manually.</p> <h2>Testing resources</h2> <p>Here's just a general list of resources we should keep handy while writing our test:</p> <ul> <li><a href="">Testing API functions</a> - This is a quick cheat sheet of some functions that are very helpful during testing. These include controlling the internal testing browser, creating users with specific permissions, and simulating clicking on links that appear in the page.</li> <li><a href="">Available assertions</a> - Assertions are how you determine whether your code is working or not - you assert that it <strong>should</strong> be working, and let the testing framework handle the rest for you. This is a library on the assertions that are available to use in our testing framework.</li> </ul> <p><a href="/how-to-write-automated-tests-for-drupal" target="_blank">read more</a></p> /how-to-write-automated-tests-for-drupal#comments drupal how to simpletest Mon, 14 Jul 2008 06:02:47 +0000 cwgordon7 17 at Paris SimpleTest Sprint, Day 2 /paris-simpletest-sprint-day-2 <p><img src="" align="right" /><br /> Only hours ago, after over three years of work on the SimpleTest module, <a href="">Dries committed the SimpleTest module to core</a>. This is an <strong>amazing</strong> achievement. Drupal is looking at getting 100% core test coverage, both unit and functional. A lot of work went into the SimpleTest module today before it was committed. We (the Drupal SimpleTest Sprinters) set up an SVN repository containing a version of Drupal with SimpleTest there as a module, and opened it up for all of us to commit. It was chaos (in a good way). Without the roadblock of patches, code was rapidly sucked into the SimpleTest module; finally Dries had to give us a SimpleTest "code freeze" so as to actually start to get stuff to work.</p> <h2>Current SimpleTest Status</h2> <p>SimpleTest is in core! What can be left to do? Actually, a lot, but first, let's go over what we've done today:</p> <ul> <li> <img src="/misc/watchdog-ok.png" /> Got SimpleTest into Core! </li> <li> <img src="/misc/watchdog-ok.png" /> Got all tests except for Trigger and Poll tests actually passing! </li> <li> <img src="/misc/watchdog-ok.png" /> Got PHPCoverage to generate a 500 MB XML file on Rok's laptop! (Though we have yet to find a script that can deal with all that data without crashing). </li> <li> <img src="/misc/watchdog-ok.png" /> Made SimpleTest's web interface <strong>pretty</strong> with the addition of <em>icons</em> and <em>assertion groups</em>! </li> <li> <img src="/misc/watchdog-ok.png" /> Got the code necessary for <a href=""></a> working! </li> </ul> <p>And then, there are <a href="">the things that are left to do</a>:</p> <p><a href="/paris-simpletest-sprint-day-2" target="_blank">read more</a></p> /paris-simpletest-sprint-day-2#comments drupal paris simpletest sprint simpletest Sun, 20 Apr 2008 23:02:07 +0000 cwgordon7 13 at Paris SimpleTest Sprint, Day 1 /paris-simpletest-sprint-day-1 <p>Today we began the <a href="">SimpleTest</a> code sprint! This is an area of <a href="">huge importance to Drupal</a>, as one of our weaknesses has proven to be the number of testers we have, particularly how small that number is. Automated testing will provide an easy way to maintain the quality of core&mdash; each time a patch is created for core, it will be sent off to a <a href="">testing server</a> where the patch will be applied to a copy of the Drupal core and all the SimpleTests run on it. If there are failures, the patch would be marked as such and whoever submitted the patch would be forced to hang their head in <strong>shame</strong>.</p> <h2>What we accomplished today</h2> <p>Today, Dries Buytaert, Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Douglas Hubler, Miglius Alaburda and I got together for 10 hours for the sole purpose of improving automated testing in core. It was great. We bounced ideas off one another, and came up with a great <a href="/paris-simpletest-sprint-day-1#unit-testing">plan for unit testing with mock functions and classes</a> without runkit. We made our <a href="/paris-simpletest-sprint-day-1#test-coverage">test coverage tests</a> work, although they are still running :). We <a href="/paris-simpletest-sprint-day-1#simpletest-pres">gave a presentation</a> to the people at Drupal Camp Paris on how to write basic functional tests for both core and contributed modules. We talked to Dries about the possibility of <a href="">getting SimpleTest into core</a>.</p> <p><a href="/paris-simpletest-sprint-day-1" target="_blank">read more</a></p> /paris-simpletest-sprint-day-1#comments drupal paris simpletest sprint simpletest Sat, 19 Apr 2008 23:18:44 +0000 cwgordon7 12 at Google sponsors two Drupal developers to Testing Sprint, Paris /google-sponsors-two-drupal-developers-to-testing-sprint-paris <p><img src="" align="right" /><br /> Thanks to the <strong>amazing</strong> <a href="">Leslie Hawthorn</a> and the <strong>awesome</strong> <a href="">Chris DiBona</a>, we can add an additional two sprinters to the list for <a href="">SimpleTest Sprint, Paris</a>! Both <a href="">Charlie Gordon</a> (me) and <a href="">Jimmy Berry</a> (aka boombatower) are now going to be at the testing sprint! Let's all thank <a href="">Google</a> for this awesome act of kindness towards the Drupal community!</p> <p>SimpleTest is critical to Drupal, not only for quality assurance, but also to <a href="">postpone the code freeze</a> so we can add more features to Drupal 7 and make it <strong>as awesome as possible</strong>.</p> <p><img src="/sites/default/files/drupal_testing.png" align="right" width = "298" /><br /> As this beautiful graph clearly shows, after Drupal has made the switch to <strong>complete SimpleTest coverage</strong> for core, the quality of Drupal will skyrocket, as we will be able to ensure that each patch committed to core does not break any of the SimpleTests, therefore <strong>less bugs and more features</strong>! When we have complete core SimpleTest coverage for Drupal, we will be free to explore awesome new features instead of spending precious time on bug hunting and bug fixing.</p> <p>Let's make that Drupal 7 release a killer! :)</p> <p><a href="/google-sponsors-two-drupal-developers-to-testing-sprint-paris" target="_blank">read more</a></p> /google-sponsors-two-drupal-developers-to-testing-sprint-paris#comments drupal google simpletest Thu, 10 Apr 2008 01:08:30 +0000 cwgordon7 11 at The power of Drupal simpletests and the simpletest revolution /the-power-of-drupal-simpletests-and-the-simpletest-revolution <div class="messages error"> <h3>If you are looking for an up-to-date SimpleTest tutorial, please see <a href="/how-to-write-automated-tests-for-drupal">my newer post</a>.</h3> </div> <p>The <a href="">Drupal simpletest module</a> is awesome! I discovered it while I was looking for a new <a href="">GHOP</a> task, and I loved the idea of it immediately. So, I claimed the task, and I'm writing now to share what I learned with you.</p> <h2>What it is</h2> <p>The simpletest module extends the php simpletest framework. Basically, it allows users to run a series of automated tests on a Drupal install.</p> <h2>Why it's useful</h2> <p>Often, new code is entered into Drupal contributed modules, and even the Drupal core, without being thoroughly tested - or even tested at all, in some situations. With simpletest, tests become so easy (without having to manually try maybe hundreds of situations) that finding and fixing bugs becomes a breeze.</p> <p><a href="/the-power-of-drupal-simpletests-and-the-simpletest-revolution" target="_blank">read more</a></p> /the-power-of-drupal-simpletests-and-the-simpletest-revolution#comments drupal ghop simpletest Mon, 24 Dec 2007 09:23:27 +0000 cwgordon7 4 at