Demo Project for Scenario Builder
This is a small demo project that shows how you can use the Scenario Builder Library for Backend and Frontend System Integration tests.
For Backend tests, see this example.
For Frontend tests, it provides a "Build Scenario" endpoint which accepts a Groovy script to use the exact same methods as Backend tests to set up a test scenario.
First, start the application.
Then send a request to the "Build Scenario" endpoint:
- POST http://localhost:8080/build-scenario
- Content-Type: text/plain
import com.innogames.scenariobuilder.Ref
var aliceRef = namedRef("alice")
var bobRef = new Ref()
scenario
.withPlayer(player -> player
.ref(aliceRef)
.withName("Alice")
)
.withPlayer(player -> player
.ref(bobRef)
.withName("Bob")
)
.withAlliance(alliance -> alliance
.withName("My Alliance")
.withMember(aliceRef)
.withMember(bobRef)
)
Response:
{
"alice": "b18d3d8b-23ea-4966-91a9-0d5d4d359442"
}
Then open http://localhost:8080/data in the browser to verify that the defined entities were created. It will print something like:
Players
Player(id=b18d3d8b-23ea-4966-91a9-0d5d4d359442, name=Alice)
Player(id=3311af50-2bc8-47e4-81b6-ef422121aba6, name=Bob)Alliances
Alliance(id=295cba9a-d53e-4c51-9ca5-61b5e4322e90, name=My Alliance, memberIds=[b18d3d8b-23ea-4966-91a9-0d5d4d359442, 3311af50-2bc8-47e4-81b6-ef422121aba6])