Skip to content

Instantly share code, notes, and snippets.

@ktoso
Created May 26, 2013 19:57
Show Gist options
  • Save ktoso/5653840 to your computer and use it in GitHub Desktop.
Save ktoso/5653840 to your computer and use it in GitHub Desktop.
import pl.project13.test.lambda.exampleimpl.Adder;
import pl.project13.test.lambda.spec.set.ClassSpecSet;
import static org.fest.assertions.Assertions.assertThat;
import static pl.project13.test.lambda.SpecDSL.describe;
public class ClassSpecTest {
// this `SpecSet` provides a new instance of the tested class for each `should`
ClassSpecSet<Adder> it = describe(Adder.class);
{
it.should("add two numbers", adder -> {
// given
int a = 1;
int b = 2;
int expected = 3;
// when
int got = adder.add(a, b);
// then
assertThat(got).isEqualTo(expected);
});
it.should("add a negative number", adder -> {
// given
int a = -1;
int b = 2;
int expected = 333; // wrong `expected`, to demo failure logging
// when
int got = adder.add(a, b);
// then
assertThat(got).isEqualTo(expected);
});
it.should("add imaginary numbers", MarkAs.pending);
}
// currently LambdaSpec has no stand alone runner, so fire it up using JUnit
@Test
public void shouldPassAllTests() throws Exception {
it.shouldPassAllTests();
}
}
@ktoso
Copy link
Author

ktoso commented May 26, 2013

A simple, yet working, proof of concept, how testing frameworks will look with Java8. Check out the rest https://github.com/ktoso/lambda-spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment