Oleaster allows you to write JUnit tests like you would write Jasmine tests.
An Oleaster JUnit test looks like this:
@RunWith(OleasterRunner.class)
public class OleasterIntroductionTest {{
describe("A suite", () -> {
it("contains a spec with an expectation", () -> {
expect(40 + 2).toEqual(42);
});
});
}}
Oleaster consists out of two independent libraries:
The Oleaster JUnit Runner gives you the option to write JUnit tests in the format shown above. Java 8 Lambda expressions are used to structure a test in suites and specifications.
Oleaster-Matcher
provides Jasmine-like Matchers (expect(..).toEqual(..)
) to validate test results. These Matchers can be used
as a replacement (or extension) for standard JUnit assertions.
Oleaster JUnit Runner Documentation
Oleaster Matcher Documentation
Source of the AudioPlayer example from the Oleaster Runner documentation.
Oleaster tests are (mostly) written with Oleaster (see: Oleaster JUnit Runner Tests and Oleaster Matcher Tests).
Travis CI builds can be found here
<dependencies>
<!-- Oleaster Matchers -->
<dependency>
<groupId>com.mscharhag.oleaster</groupId>
<artifactId>oleaster-matcher</artifactId>
<version>0.2.0</version>
</dependency>
<!-- Oleaster JUnit runner -->
<dependency>
<groupId>com.mscharhag.oleaster</groupId>
<artifactId>oleaster-runner</artifactId>
<version>0.2.0</version>
</dependency>
<!-- Of course a JUnit runner can only be used with JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
This software is licensed under the Apache 2 license, quoted below.
Copyright 2017 Michael Scharhag
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.