Created
May 26, 2013 19:57
-
-
Save ktoso/5653840 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple, yet working, proof of concept, how testing frameworks will look with Java8. Check out the rest https://github.com/ktoso/lambda-spec