I am looking for BDD java framework with possibility to reuse Given & Then for Unit and Integration tests.
In other words 1. Given some precondition. 2. When - depending on the environment 3. Then verify results of When
I want to be able by changing When, and keeping Given and Then intact, change the type of the test, for example in simple REST service:
- UNIT test
- Given
- generates some POJO object
- When
- receives POJO from Given
- calls internal service with this POJO
- receives result in POJO form from the service
- forwards received POJO to Then
- Then
- verifies POJO from When
- Given
- INTEGRATION test
- Given
- generates some POJO object
- When
- receives POJO from Given
- encrypts POJO in external service format
- calls external service
- receives result in external service format from exposed service
- transforms received result in POJO
- forwards received POJO to Then
- Then
- verifies POJO from When
- Given
So in example, Given and Then behave the same way, for both integration and unit tests, and by simply changin When the scope of the test goes from UNIT to INTEGRATION.
Can someone point me in the right direction?
I don't want to reinvent the wheel