Skip to content
Ben Limmer edited this page Nov 5, 2013 · 1 revision

What's the deal with test vs. integTest?

Great question! The test and integTest directories story different kinds of test cases.

test

The tests in the src/test directory are intended as low-level unit tests. They are meant to exercise very narrow code paths. They'll help you write better code as you go. Maybe give TDD or BDD a try as you work on new or existing widgets.

Also, please note that failing tests in the src/test directory will fail the build. This means that every test in this directory should be able to be run with or without a display. If you need to access the Display or other SWT components that require a non-headless machine, please use integTest.

integTest

The tests in the src/integTest directory are intended for mid-level tests. They exercise wider code paths and likely require a machine with a display (or xvfb). Tests in here might do things like creating a Display to open a Shell on the screen.

Do not worry about writing tests that support headless machines in this directory.

Gotchas

There are several gotchas that we've run into thus-far in the project with our tests. We'll document them here.

integTest

new Display()

Since Gradle runs the tests in parallel threads, you need to ensure you're not using new Display() in any of your integTests. You'll need to use the static call Display.getDefault() for things to work properly.

Linux + shell.setLocation()

For some reason, Linux does not pay attention to a location set on a Shell object until it's opened. So, if you need to to rely on a Shell appearing in a particular location, be sure to run shell.open() before you go about your logic-y business.