-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an end-to-end test that executes an all-AI game to completion. (#…
…10522) Add an end-to-end test that executes an all-AI (hard AI) game to completion. Currently, only doing this on the very simple "mapmaking tutorial map", which exercises sea zones and amphib invasions. In my testing, this takes 1 min to run and a game completes in 24 rounds. Also adds a few more maps to GameSaveTest.
- Loading branch information
Showing
5 changed files
with
187 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
46 changes: 46 additions & 0 deletions
46
smoke-testing/src/test/java/games/strategy/engine/data/AiGameTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package games.strategy.engine.data; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.empty; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
import games.strategy.engine.framework.ServerGame; | ||
import games.strategy.engine.framework.startup.ui.panels.main.game.selector.GameSelectorModel; | ||
import games.strategy.triplea.delegate.EndRoundDelegate; | ||
import java.io.IOException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
/** | ||
* End-to-end test that starts all-AI games on a selected set of maps and verifies they conclude | ||
* with a victory for one of the sides. This ensures the AI code doesn't run into errors and can | ||
* make progress towards victory conditions. | ||
*/ | ||
@Slf4j | ||
public class AiGameTest { | ||
@BeforeAll | ||
public static void setUp() throws IOException { | ||
GameTestUtils.setUp(); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"map_making_tutorial,map/games/Test1.xml", | ||
}) | ||
void testAiGame(String mapName, String mapXmlPath) throws Exception { | ||
GameSelectorModel gameSelector = GameTestUtils.loadGameFromURI(mapName, mapXmlPath); | ||
ServerGame game = GameTestUtils.setUpGameWithAis(gameSelector); | ||
game.setStopGameOnDelegateExecutionStop(true); | ||
game.startGame(); | ||
assertThat(game.isGameOver(), is(true)); | ||
assertThat(game.getData().getSequence().getRound(), greaterThan(2)); | ||
EndRoundDelegate endDelegate = (EndRoundDelegate) game.getData().getDelegate("endRound"); | ||
assertThat(endDelegate.getWinners(), not(empty())); | ||
log.info("Game completed at round: " + game.getData().getSequence().getRound()); | ||
log.info("Game winners: " + endDelegate.getWinners()); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.