Skip to content

Devel GTK JUnitTests

Simeon Andreev edited this page Feb 23, 2023 · 1 revision

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:

 /eclipse.platform.swt/tests/org.eclipse.swt.tests       # Where  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. Additionally, the Browser widget can be tested using the AllBrowserTests.java file. This is useful for checking regressions after working on Webkit or Browser related bugs.

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
Clone this wiki locally