Update:Remora Testing

Revision as of 01:28, 30 August 2006 by Shaver (talk | contribs)

Why do we write tests?

Because shut up, that's why.

Also!

We write tests because they let us go faster, even early in development, by revealing downstream effects of changes earlier.

We write tests because they improve the quality of our code, by pushing us to factor better, reduce dependencies on other state, and keep control flow simpler.

We write tests because they document code better than comments, and because seeing a green bar makes us feel tingly inside, like when Sally held our hand on the school bus in grade 4.

We write tests the best we can, knowing that we won't be perfect, and adding more tests as we encounter them. We know that writing tests as we write code will encourage us to make smaller changes and focus on the specific problem at hand. We are learning to trust and fear the feeling in our stomach that says that a change is risky because there isn't a good test for some of the things it effects.

We think morgamic is pretty cute. But we don't have a test for it, so we're not really confident.

Model Tests

Example forthcoming.

Controller Tests

Controller tests must be located in the models directory. Example will be posted here eventually.

Component Tests

Components can be tested as displayed in the following example. Note that these must be saved in the models directory.

File path: /var/www/html/fligtar/app/tests/app/cases/models/rdf.test.php

Web path: http://142.204.140.147:8080/fligtar/tests/cases?case=models%2Frdf.test.php&app=true

<?php
class RdfTest extends UnitTestCase {
        //Setup the RDF Component
        function setUp() {
                loadComponent('Rdf');
                $this->Rdf =& new RdfComponent();
        }

        //Make sure there are no PHP errors
        function testNoErrors() {
                $this->assertNoErrors();
        }

        //Make sure the XML returns an array of parsed data
        function testIsArray() {
                $results = $this->Rdf->parseInstallManifest($this->manifestData);
                $this->assertIsA($results, 'array');
                $this->returnedArray = $results;
        }
}
?>