Test Library BDD (RSpec-like) for Java

Now that we have the lambda expression, it should be able to have a Java module testing library that offers syntax similar to (say) RSpec syntax. I imagine something like:

describe("some behavior", () -> { beforeEach(() -> { // do some initialization... }); describe("sub behavior 1", () -> { // some assertions ... }); describe("sub behavior 2", () -> { // some assertions .... }); }); 

Is there such a library there?

+5
source share
2 answers

Afaik, Oleaster is the lib that does this.

Oleaster allows you to write JUnit tests, for example, write Jasmine tests.

The Oleaster JUnit test is as follows:

 @RunWith(OleasterRunner.class) public class OleasterIntroductionTest {{ describe("A suite", () -> { it("contains a spec with an expectation", () -> { expect(40 + 2).toEqual(42); }); }); }} 
+6
source

Please consider spock , it was inspired by rspec and others.

He just reached 1.0.

On the page...

In behavior-driven development, customer-oriented features (called stories) are described in a once-then-time format. Spock directly supports this specification style with data: label:

 > given: "an empty bank account" // ... > > when: "the account is credited $10" // ... > > then: "the account balance is $10" // ... As noted 
+3
source

All Articles