您好,我无法解决问题,我正在对一个博彩游戏进行测试,在每次测试开始时,我需要为数据库创建一个新游戏,我在此游戏上运行测试,然后将其删除,因此数据库没有充斥新游戏,因为我运行了大约20项要求这样做的测试。但是,我发现的问题是,如果对用户界面进行了一些更改,所有这些测试可能会失败,并且会卡在数据库中的20个游戏中, game.deletegame()尚未运行并删除了游戏。如果测试未完成,有没有办法让我运行它?
这是我的代码:
public class register_from_pick_screen extends ConditionsWebDriverFactory{
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
@Test
public void register_from_pick()throws Exception{
CreateGameSD game = new CreateGameSD();
game.create_Public_Free_to_Play_game_named_with_description(TestGames.test_web_game,TestGames.test_web_game_description);
GameLobby lobby = new GameLobby();
lobby.clickElementWithName(TestGames.test_web_game);
LeaderBoard leaderboard = new LeaderBoard();
GameId gameid = new GameId();
gameid.game_id();
leaderboard.joinGame();
FixturesScreen fixtures = new FixturesScreen();
fixtures.four_picks_make();
fixtures.picks_match_total();
fixtures.pick_removal_test();
fixtures.submit_picks();
Login login = new Login();
login.select_register_from_login();
Register register = new Register();
register.register_in_pick_screen();
fixtures.submit_picks();
PickReceipt pick = new PickReceipt();
pick.your_in_the_game();
register_from_login_form.addResultForTestCase("16788",TEST_CASE_PASSED_STATUS," ");
register_from_login_form.addResultForTestCase("17143",TEST_CASE_PASSED_STATUS," ");
game.delete_game();
}
}
答案 0 :(得分:1)
不确定是否要成功运行游戏就删除它们,但是如果您想删除失败的游戏,则可以尝试以下操作:
创建一个新的布尔变量,如果您的游戏运行,则将其设置为true;否则将其保持为false。
boolean runSuccess = false;
//game code runs here
//at end of game code add line: runSuccess = true;
//if game code fails to run completely
//runSuccess stays false
if (runSuccess = false)
game.delete_game();
如果您想使游戏自行删除,只需在打开任何其他游戏之前将game.delete_game()方法添加到代码开头,以使其循环进入game.delete_game()无论。在您的pick
循环菜单中添加该方法,以便每次游戏运行时都可以运行。