I wanted to give a brief description of what I did to get Teiid Designer's tests running with the JBoss Tycho build. Before I get into the details I wanted to let you know of the new and deleted projects so you can update your trunk workspace.
These projects have been deleted because they contained no tests:
- tests/org.teiid.designer.metamodels.dependency.test
- tests/org.teiid.designer.metamodels.webservice.test
- tests/org.teiid.designer.modelgenerator.xml.test
These projects have been added and contain only test support classes (so they do not contain any tests):
- tests/org.teiid.core.designer.test.framework
- tests/org.teiid.designer.core.test.framework
- tests/org.teiid.designer.jdbc.test.framework
Now onto the details ....
Our test approach, which is a very common one, is to have one test plugin for each plugin we want to test; and one test class for each class we want to test. Each test class has one or more tests that can be executed using JUnit. Eclipse allows a developer, using the applicable launcher, to run a test either as a "JUnit Test" or as a "JUnit Plug-in Test." A "JUnit Plug-in Test" runs the test in an OSGi environment while the "JUnit Test" does not. Our Teiid Designer JBoss Tycho build runs tests in an OSGi environment.
Some of our tests would run successfully as a "JUnit Test" but would fail when run as a "JUnit Plug-in Test." Obviously, the tests failing when run as a "JUnit Plug-in" test also fail during the Tycho build. One of the biggest reasons for the failed tests was that the test code was calling protected and package private methods in the classes they were testing. In an OSGi environment, one plugin cannot call protected and package private methods of classes contained in another plugin (even if the test class and the class it was testing have the same package). Using an OSGi fragment gets passed this restriction.
So, I made all our test plugins into test fragments. Fragments must have a host plugin, so in our case, the host plugin is always the plugin the test fragment is testing. After converting to fragments, our tests were allowed to call protected and package private methods in classes found in its host plugin. (Note: Another benefit of the fragment and host plugin relationship is that the fragment inherits all the dependencies from the host plugin.) But now another OSGi restriction got in the way: fragments cannot have dependencies to other fragments.
Quite a few of our tests reference test support classes which were now found in other test fragments. As I just mentioned, OSGi does not allow fragment to fragment dependencies. The solution was to move those test support classes to new test support plugins. And that is exactly what I did. All of those test support classes moved to the new "*.test.framework" plugins mentioned earlier. These new framework plugins do not contain any tests.
After making the above changes we are still left with with some problems. The big problem now is getting our tests that use PowerMock and the PowerMockRunner to work. I have not figured out how to get that to work in OSGi environment (they all run successfully as a "JUnit Test"). I've written 3 JIRAs related to the remaining testing problems: TEIIDDES-802, TEIIDDES-803, and TEIIDDES-813.
Here are the Teiid Designer projects whose tests are currently not being run during the Tycho build:
- org.teiid.designer.core.test
- org.teiid.ddl.importer.test
- org.teiid.dqp.test
- org.teiid.jdbc.relational.test
- org.teiid.jdbc.test
- org.teiid.vdb.test
When these project's tests are ready to be run during the Tycho build just uncomment the applicable line(s) in tests/pom.xml and in tests/org.teiid.designer.runtime.feature/feature.xml.
Item of Interest: Test fragments must add dependencies to any plugin having an extension for any extension point your tests are relying on. These are runtime dependencies. The big one here is DatatypeManager whose extension is found in the org.teiid.designer.sdt plugin. Any test that uses ModelerCore will need to add the SDT plugin as a dependency.
Comments