Difference between revisions of "Database Testing"
(Created page with "== Overview == This section covers a JUnit-based testing framework for making tests, which use the Simantics Database. The framework handles two separate cases *POJO JUnit tes...") |
|||
Line 46: | Line 46: | ||
Note that the launchers can be configured using .launch - files. | Note that the launchers can be configured using .launch - files. | ||
− | == POJO | + | == POJO details == |
The POJO testing framework can be set up by running a customized org.simantics.db.testing.cases.FreshDatabaseTest e.g. | The POJO testing framework can be set up by running a customized org.simantics.db.testing.cases.FreshDatabaseTest e.g. |
Revision as of 11:19, 8 July 2011
Overview
This section covers a JUnit-based testing framework for making tests, which use the Simantics Database. The framework handles two separate cases
- POJO JUnit tests, where tests are executed without OSGi and with some configuration restrictions
- OSGi JUnit tests, where tests are executed in OSGi based on the current workspace
General
Both testing approaches use similar test suites. Below is an example
public class Tests { public static Test suite() throws Exception { TestSuite suite = new TestSuite("My suite"); //$JUnit-BEGIN$ suite.addTestSuite(FreshDatabaseTest.class); suite.addTestSuite(MyTest.class); //$JUnit-END$ return suite; } }
The first test is used to set up the initial database and upon which the other tests operate. In POJO mode the first test also needs to give some configuration settings as described below.
The test framework can be found in org.simantics.db.testing. The framework contains
- Test case templates for extending in org.simantics.db.testing.base
- Generic test cases in org.simantics.db.testing.cases
Running the tests
To run the tests open a context menu for the suite class (see example above) and
- To run in POJO, select Run As .. JUnit Test
- To run in OSGi, select Run As .. JUnit Plug-in Test
The Plug-in tests need to be run as 'all workspace and enabled target plug.ins' and as application '[No Application] - Headless Mode]'
Note that the launchers can be configured using .launch - files.
POJO details
The POJO testing framework can be set up by running a customized org.simantics.db.testing.cases.FreshDatabaseTest e.g.
public class InitializationTest extends FreshDatabaseTest {
@Override public void configure(TestSettings settings) {
settings.setAdapters(new String[] { "org.simantics.db.layer0/adapters.xml", "org.simantics.spreadsheet.graph/adapters.xml" }); settings.setOntologies(new String[] { "/org.simantics.spreadsheet.ontology/graph.tg", });
settings.setWorkspace(new File("..")); settings.setInitialized();
}
}
OSGi testing
The Plug-in testing framework applies all adapters found from the workspace.
org.simantics.db.testing.cases.FreshDatabaseTest can be used to install all available ontologies from the workspace.