-
Notifications
You must be signed in to change notification settings - Fork 95
UnitTests
= Unit Tests = Ideally, CSS code is developed in a test-driven manner, and tests are executed as part of an integration build.
Tests should have the following features:
- Automatically executable AND terminating without any user interaction or user supervision.
- Not taking an exceptional long time, if it is not necessary for the test. ** E.g. check for database connections in the test setup once. Do not wait for connection timeout for any test to figure out that the test eventually fails.
- Do not use excessive logging (there'S no need if no one's watching), concentrate on important test debug info.
- Use a Logger, not the standard console, if possible.
We distinguish between different types of tests, which are identified by the filename and/or annotations
- Plain JUnit tests: {{{*UnitTest.java}}}
- JUnit Plug-in tests that need the Eclipse runtime: {{{*UiPluginTest.java}}}
- JUnit Plug-in tests that need the runtime but no GUI: {{{*HeadlessTest.java}}}
- A demo that requires user input or other interaction. Not a real test, but happens to be implemented with JUnit: {{{*Demo.java}}}
There is a plugin org.platform.testsuite that implements a testsuite that is configured by different launch configurations:
- AllTests.launch (any *Test.class) ** started vs the common css product with a lot of perm gen space
- HeadlessTests.launch (any *HeadlessTest.class) ** started vs the headless application
- UnitTests.launch (any *UnitTest.class) ** started vs the headless application
- UiPluginTests.launch (any *UiPluginTest.class) ** started vs the common css product
Any of these configurations starts a JUnit Plugin test that shall load all classes from all plugins present and analyse them for being a test.
Valid bundle roots are currently:
- org.csstudio
- org.remotercp
- de.desy
Blacklisted bundles (not considered):
- org.csstudio.platform.libs (is supposed to contain loads of classes from 3rd parties)
Any loaded class is analysed to be either an extension of junit.framework.TestCase or containing public methods annotated with @org.junit.Test, if so and it is a member of a valid bundle, the class is added to the test suite. If the class is a test, but does not end on *Test, a warning is logged, as this class is not added to the testsuite. If the class is not a test, but ends on *Test.class, another warning is printed (often observed for demo applications).