gpt4 book ai didi

java - 如果测试未完成则运行方法

转载 作者:行者123 更新时间:2023-11-28 21:20:51 25 4
gpt4 key购买 nike

您好,我有一个我无法弄清楚的问题,我在一个博彩游戏上运行测试,在每次测试开始时,我需要为数据库创建一个新游戏,我在这个游戏上运行我的测试,然后删除它,所以当我运行大约 20 个需要这个的测试时,数据库不会充满新游戏。但是,我发现的问题是,如果有一些 UI 更改,所有这些测试都可能会失败,并且我坚持使用数据库中的 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();
}
}

最佳答案

不确定是否要在游戏成功运行时将其删除,但如果您希望在游戏运行失败时将其删除,您可以尝试以下操作:

创建一个新的 boolean 变量,如果您的游戏运行则设置为 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 循环菜单中添加该方法,以便它在每次游戏运行时运行。

关于java - 如果测试未完成则运行方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52059492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com