<commit_before><?xml version="1.0"?>
<page title="Running the tests, the easy way with autorun" here="Autorunning test cases">
    <long_title>[experimental] Running the tests, the easy way with autorun</long_title>
    <content>
        <div class="experimental">
            Careful : this documentation refers to un-released code. It's only available in CVS.
        </div>
        <p>
            You started with unit testing not so long ago and
			this is what you came up with... A file <em>test_of_all_modules.php</em>
			containing :
<php><![CDATA[
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

$group = new GroupTest();
$group->addTestFile('test_of_module_ship.php');
$group->addTestFile('test_of_module_pay.php');

$group->run(new HtmlReporter());
?>
]]></php>
        </p>
        <p>
            But now you have a new way of shipping your socks overseas. Easily
			you just need to add a new file <em>test_of_module_ship_overseas.php</em>
			to your test runner... Quickly enough, you end up with a lot of file :
<php><![CDATA[
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

$group = new GroupTest();
$group->addTestFile('test_of_module_ship.php');<strong>
$group->addTestFile('test_of_module_ship_overseas.php');
$group->addTestFile('test_of_module_ship_france.php');
$group->addTestFile('test_of_module_ship_uk.php');
$group->addTestFile('test_of_module_ship_us.php');
...</strong>
$group->addTestFile('test_of_module_pay.php');

$group->run(new HtmlReporter());
?>
]]></php>
        </p>
        <p>
            As you list grows, running the test suite becomes too time-
			consuming : the tests are actually slowing you down while writing code.
        </p>
        <p>
			<a class="target" name="autorun"><h2>Introducing 'autorun'</h2></a>
        </p>
        <p>
			What we're looking for now is a way to run one test at a time
			and still be able to run every one of them easily...
			What if we could just write - in a console for example :
			<div class="console">
                home: /$ <strong>php test_of_module_ship_us.php</strong>
            </div>
			and still be able to do :
			<div class="console">
                home: /$ <strong>php test_of_all_modules.php</strong>
            </div>
			It's possible now : you just need to add one include at the top of
			each test case. Your <em>test_of_module_ship_us.php</em> will
			look like :
<php><![CDATA[
<?php<strong>
require_once(dirname(__FILE__) . 'simpletest/autorun.php');</strong>

class TestUsingParcelForce extends UnitTestCase {
  function testParcelForceIsFine() {
    $this->assertTrue(true);
  }
}

class TestUsingMyOwnAirplane extends UnitTestCase {
  function testUsingMyOwnAirplaneOnlyWorksForSmallGifts() {
    $this->assertFalse(false);
  }
}
?>
]]></php>
        </p>
        <p>
            <a class="target" name="preference"><h2>Setting the prefered runner</h2></a>
        </p>
		<p>
			PHP is mainly for web stuff : I'm guessing your first test platform is
			a web browser, Firefox, Opera or Safari usually. And SimpleTest comes with
			a nice HTML interface : it's the one we want to use when running one file.
			We can tell our <em>test_of_module_ship_us.php</em> to use it by default :
<php><![CDATA[
<?php
require_once(dirname(__FILE__) . 'simpletest/autorun.php');<strong>
SimpleTest :: prefer(new HtmlReporter());</strong>

class TestUsingParcelForce extends UnitTestCase {
  function testParcelForceIsFine() {
    $this->assertTrue(true);
  }
}

class TestUsingMyOwnAirplane extends UnitTestCase {
  function testUsingMyOwnAirplaneOnlyWorksForSmallGifts() {
    $this->assertFalse(false);
  }
}
?>
]]></php>
		</p>
		<p>
			We get a nice green bar :
            <div class="demo">
                <h1>GroupTest</h1>
                <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">2/2 test cases complete:
				<strong>2</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
            </div>
		</p>
        <p>
			<a class="target" name="autorun-for-suites"><h2>Autorun for test suites</h2></a>
        </p>
        <p>
            So we've managed to get the time spent running the test under control
			during the coding period. We now want to make sure all the tests still
			pass, all the time. Or at least after every commit to the SVN (or CVS)
			trunk.
        </p>
        <p>
            Such process is called <em>continuous integration</em> : <NAME> writes
			really well about this practice <cite>where members of a team integrate their
			work frequently [...]. Each integration is verified by an automated buid
			(including test) to detect integration errors as quickly as possible</cite>.
			So I can just give you the link :
			<a href="http://www.martinfowler.com/articles/continuousIntegration.html">Continuous Integration</a>.<commit_msg>Corrections after first comments : 1/ require_once('simpletest/autorun.php'); everywhere 2/ TestSuite now replaces GroupTest<commit_after><?xml version="1.0"?>
<page title="Running the tests, the easy way with autorun" here="Autorunning test cases">
    <long_title>[experimental] Running the tests, the easy way with autorun</long_title>
    <content>
        <div class="experimental">
            Careful : this documentation refers to un-released code. It's only available in CVS.
        </div>
        <p>
            You started with unit testing not so long ago and
			this is what you came up with... A file <em>test_of_all_modules.php</em>
			containing :
<php><![CDATA[
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

$group = new TestSuite();
$group->addTestFile('test_of_module_ship.php');
$group->addTestFile('test_of_module_pay.php');

$group->run(new HtmlReporter());
?>
]]></php>
        </p>
        <p>
            But now you have a new way of shipping your socks overseas. Easily
			you just need to add a new file <em>test_of_module_ship_overseas.php</em>
			to your test runner... Quickly enough, you end up with a lot of file :
<php><![CDATA[
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

$group = new TestSuite();
$group->addTestFile('test_of_module_ship.php');<strong>
$group->addTestFile('test_of_module_ship_overseas.php');
$group->addTestFile('test_of_module_ship_france.php');
$group->addTestFile('test_of_module_ship_uk.php');
$group->addTestFile('test_of_module_ship_us.php');
...</strong>
$group->addTestFile('test_of_module_pay.php');

$group->run(new HtmlReporter());
?>
]]></php>
        </p>
        <p>
            As you list grows, running the test suite becomes too time-
			consuming : the tests are actually slowing you down while writing code.
        </p>
        <p>
			<a class="target" name="autorun"><h2>Introducing 'autorun'</h2></a>
        </p>
        <p>
			What we're looking for now is a way to run one test at a time
			and still be able to run every one of them easily...
			What if we could just write - in a console for example :
			<div class="console">
                home: /$ <strong>php test_of_module_ship_us.php</strong>
            </div>
			and still be able to do :
			<div class="console">
                home: /$ <strong>php test_of_all_modules.php</strong>
            </div>
			It's possible now : you just need to add one include at the top of
			each test case. Your <em>test_of_module_ship_us.php</em> will
			look like :
<php><![CDATA[
<?php<strong>
require_once('simpletest/autorun.php');</strong>

class TestUsingParcelForce extends UnitTestCase {
  function testParcelForceIsFine() {
    $this->assertTrue(true);
  }
}

class TestUsingMyOwnAirplane extends UnitTestCase {
  function testUsingMyOwnAirplaneOnlyWorksForSmallGifts() {
    $this->assertFalse(false);
  }
}
?>
]]></php>
        </p>
        <p>
            <a class="target" name="preference"><h2>Setting the prefered runner</h2></a>
        </p>
		<p>
			PHP is mainly for web stuff : I'm guessing your first test platform is
			a web browser, Firefox, Opera or Safari usually. And SimpleTest comes with
			a nice HTML interface : it's the one we want to use when running one file.
			We can tell our <em>test_of_module_ship_us.php</em> to use it by default :
<php><![CDATA[
<?php
require_once('simpletest/autorun.php');<strong>
SimpleTest :: prefer(new HtmlReporter());</strong>

class TestUsingParcelForce extends UnitTestCase {
  function testParcelForceIsFine() {
    $this->assertTrue(true);
  }
}

class TestUsingMyOwnAirplane extends UnitTestCase {
  function testUsingMyOwnAirplaneOnlyWorksForSmallGifts() {
    $this->assertFalse(false);
  }
}
?>
]]></php>
		</p>
		<p>
			We get a nice green bar :
            <div class="demo">
                <h1>TestSuite</h1>
                <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">2/2 test cases complete:
				<strong>2</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
            </div>
		</p>
        <p>
			<a class="target" name="autorun-for-suites"><h2>Autorun for test suites</h2></a>
        </p>
        <p>
            So we've managed to get the time spent running the test under control
			during the coding period. We now want to make sure all the tests still
			pass, all the time. Or at least after every commit to the SVN (or CVS)
			trunk.
        </p>
        <p>
            Such process is called <em>continuous integration</em> : <NAME> writes
			really well about this practice <cite>where members of a team integrate their
			work frequently [...]. Each integration is verified by an automated buid
			(including test) to detect integration errors as quickly as possible</cite>.
			So I can just give you the link :
			<a href="http://www.martinfowler.com/articles/continuousIntegration.html">Continuous Integration</a>.
{'fraction_non_alphanumeric': 0.1252138902868646, 'fraction_numerical': 0.0036235530951182686, 'mean_word_length': 3.325642141924249, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 2, '>': 225, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3855351', 'n_tokens_mistral': 3277, 'n_tokens_neox': 3083, 'n_words': 958}