Download 1. .bookmarks

Transcript
package org.geotools.module;
import org.geotools.map.BoundingBox;
/**
* Unit test for BoundingBox.
*
* @author Cameron Shorter
*/
public class HelloWorldTest extends TestCase {
/** Test suite for this test case */
private TestSuite suite = null;
/**
* Constructor with test name.
*/
public HelloWorldTest(String testName) {
super(testName);
}
/**
* Main for test runner.
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Required suite builder.
* @return A test suite for this unit test.
*/
public static Test suite() {
TestSuite suite = new TestSuite(HelloWorldTest.class);
return suite;
}
/**
* Initialize variables
*/
protected void setUp() {
// initialize variables
}
/** Test normal constuctors. */
public void testHello(){
assertTrue("HelloWorld should return null is true",HelloWorld.isNull());
}
}
Testing with junit is as easy as copying HelloWorldTest.java and adding more tests, and then executing it. If you want more information, look
at the junit documentation or read one of the many junit tutorials.
Online Tests
We make use of a naming convention, ie ensure the name of your TestCase ends in OnlineTest, to indicate the use of external web services and
databases. If a unit test requires a network connection to pass, it is an online test.
These tests will be skipped as part of the normal build process, but will be executed by certain build boxes.
In addition to the naming convention, JUnit 3 online tests should extend the OnlineTestCase class, since it will extract connection parameters
from fixture properties files in the user's ~/.geotools directory with minimal hassle. Test cases extending this class will need to implement the
getFixtureId() method which will return the identifier for a fixture; a fixture id of "postgis.typical" will attempt to read the file
"~/.geotools/postgis/typical.properties".
Fixture property files allow site-specific connection information such as database authentication credentials to be provided outside the public
GeoTools code base. For example, a developer might provide access to a test database in their own PostGIS instance, but not want to share this