Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "SWT/Devel/Gtk/JUnitTests"
(Created page with "= Background = SWT comes with a set of JUnit test cases that test a wide cross section of widgets in the SWT codebase. Running these tests after writing a patch is useful to s...") |
m |
||
Line 19: | Line 19: | ||
* Select "JUnit 4" and click finish | * Select "JUnit 4" and click finish | ||
* Run the tests again, they should work | * Run the tests again, they should work | ||
+ | |||
+ | = Running jUnit tests across multiple versions of GTK = | ||
+ | Before submitting a patch, you generally want make sure that your code passes all jUnit tests on all major versions of gtk. | ||
+ | Running them one by one is tedious. A script is provided to run them in a batch. | ||
+ | |||
+ | TODO - Link to script in repo. |
Revision as of 10:42, 24 May 2016
Contents
Background
SWT comes with a set of JUnit test cases that test a wide cross section of widgets in the SWT codebase. Running these tests after writing a patch is useful to see if your patch breaks anything else in addition to your changes.
Location
The tests are located in the org.eclipse.swt.tests project, assuming you imported all the projects in the SWT git repository. If you have not done so, you can import the project from this path:
<git location>/eclipse.platform.swt/tests/org.eclipse.swt.tests # Where <git location> is the location of your gitroot.
Running Tests
The tests that concern most SWT developers will be the AllNonBrowserTests.java file. This contains the non-browser tests that will test a variety of widgets. To run it, open the file, and click the run button. Eclipse should automatically load the JUnit test runner and run the tests. Make sure you run the tests in Gtk3 and Gtk2, as that can make quite a difference depending on the patch you are testing.
NoDef/Initialization Errors
You may encounter the following error (or something similar) after upgrading your version of Eclipse or running the JUnit test suite for the first time:
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
This is fixed by editing your build path for the org.eclipse.swt.tests project. To do, execute the following steps:
- Right click the project in the Package Explorer and hover over "Build Path"
- Select "Add Libraries" from the side menu
- Select "JUnit" and click next
- Select "JUnit 4" and click finish
- Run the tests again, they should work
Running jUnit tests across multiple versions of GTK
Before submitting a patch, you generally want make sure that your code passes all jUnit tests on all major versions of gtk. Running them one by one is tedious. A script is provided to run them in a batch.
TODO - Link to script in repo.