https://github.com/avojak/swt-unit
SWT unit testing utilities
https://github.com/avojak/swt-unit
java junit swt unit-testing
Last synced: 2 months ago
JSON representation
SWT unit testing utilities
- Host: GitHub
- URL: https://github.com/avojak/swt-unit
- Owner: avojak
- License: gpl-3.0
- Archived: true
- Created: 2017-04-25T02:36:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-06T16:10:52.000Z (over 6 years ago)
- Last Synced: 2025-08-02T05:30:32.101Z (3 months ago)
- Topics: java, junit, swt, unit-testing
- Language: Java
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# swt-unit
[](https://travis-ci.org/avojak/swt-unit) [](https://coveralls.io/github/avojak/swt-unit?branch=1.0) [](http://www.gnu.org/licenses/gpl-3.0) [](http://repo.thedesertmonk.com/artifactory/webapp/#/artifacts/browse/tree/General/maven-release/com/thedesertmonk/util/swt-unit/1.0)
Generally I try to avoid directly testing [SWT](https://www.eclipse.org/swt/) controls, however there are times where it is useful to verify their state. The aim of this project is to provide utilities which facilitate unit tests around SWT widgets and controls.
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
### Prerequisites
It is expected that the appropriate SWT .jar be present at runtime.
### Installing
The artifact may be pulled into a Maven project via the `pom.xml` file.
*Note: swt-unit is a testing utility and therefore should be specified with the `test` scope*.
#### Release Versions (Recommended)
```xml
com.thedesertmonk.util
swt-unit
1.0
test```
```xmlthedesertmonk-release
TheDesertMonk Maven Release Repository
http://repo.thedesertmonk.com/maven-release```
#### Snapshot Versions
```xml
com.thedesertmonk.util
swt-unit
1.0-SNAPSHOT
test```
```xmlthedesertmonk-snapshot
TheDesertMonk Maven Snapshot Repository
http://repo.thedesertmonk.com/maven-snapshot```
## Example Usage
### `WidgetHierarchyInspector`
The `WidgetHierarchyInspector` will enumerate the child `Control` objects of a given a parent `Composite`.
Suppose you have the following hierarchy:
```java
Shell s = new Shell(display);
Composite c = new Composite(s, SWT.NONE);
ScrolledComposite sc = new ScrolledComposite(s, SWT.V_SCROLL);
Button b = new Button(s, SWT.PUSH);
```The `getChildren(Composite, Class)` method will behave as follows:
```java
// A List containing a single element: b
List children = WidgetHierarchyInspector.getChildren(s, Button.class);
```
```java
// A List containing a single element: sc
List children = WidgetHierarchyInspector.getChildren(s, ScrolledComposite.class);
```
```java
// A List containing two elements: s and sc (ScrolledComposite is a subclass of Composite)
List children = WidgetHierarchyInspector.getChildren(s, Composite.class);
```
```java
// An empty List
List children = WidgetHierarchyInspector.getChildren(s, Label.class);
```## Running the tests
The [JUnit](http://junit.org/junit4/) tests can be run via the following Maven command:
```
man clean verify
```## Built With
* [Maven](https://maven.apache.org/) - Dependency Management
* [Travis CI](https://travis-ci.org) - Continuous Integration and Deployment
* [JaCoCo](http://www.eclemma.org/jacoco/) - Code Coverage## Versioning
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/avojak/swt-unit/tags).
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details.