where do i start writing a plugin test? I wrote some plugins for toys and would like to start making TDD with my plugins.
If your plugin is RCP (Rich Client Platform) plugins with SWT, you can use SWTBot .Those tests can be encapsulated in JUnit one:
If your plugins are OSGi-based, you should be aware that the OSGi package runs its own class loader, and therefore classes should not be in the same package. See " Is OSGi Opposing JUnit Tests? "
Build your test fragment plugin.One problem is that other plugins cannot access classes defined in fragments (as Patrick Paulin points to a more detailed discussion of fragments in unit tests ).Another problem is that plugin.xml in the fragment is ignored. And so you are testing the plugin, you cannot contribute
plugin.xml
From Patrick's article:
Fragments look like a plugin from the outside. It is presented as a separate project in your workspace, it contains a manifest that describes its contents, it is built and deployed as a jar. What makes a fragment different is that it contributes its resources at runtime to a single host module. Therefore, classes in the fragment are loaded by the host plugin class loader.
By placing our unit tests in fragments, we can provide our tests for access to the non-public methods of the classes being tested. In addition, since the source code and the test code are actually part of the same plug-in, there are no problems with unexported packages. Test classes will have access to all plug-in packages, regardless of whether they are exported or not.The main disadvantage of this fragment-based approach is that it is difficult to combine unit tests into a master test suite. Although it is easy to create a test suite that includes tests within a fragment, it is not so easy to create a test suite that includes tests in several fragments.
By placing our unit tests in fragments, we can provide our tests for access to the non-public methods of the classes being tested. In addition, since the source code and the test code are actually part of the same plug-in, there are no problems with unexported packages. Test classes will have access to all plug-in packages, regardless of whether they are exported or not.
The main disadvantage of this fragment-based approach is that it is difficult to combine unit tests into a master test suite. Although it is easy to create a test suite that includes tests within a fragment, it is not so easy to create a test suite that includes tests in several fragments.
If your plugins need only simple testing, JUnit test is enough
Create a new BookTest test case in the test.yourpackage package, right-click on the package and select " New > JUnit Test Case ".
New > JUnit Test Case