Test framework: add commands for real time checks/assertions
See original GitHub issueCurrent test framework can do checks (assertions) only on game’s end. That’s a big limit – devs need to create plenty of tests to reproduce and check each step (e.g. you can test only final result). But with real time checks you can assert errors in the middle of the game (e.g. you can test all progress to final result).
Framework must allow to insert checks like other player commands and generate standard test errors:
- color (have or not have) –
checkColor; - card type (have or not have);
- card subtype (have or not have) –
checkSubType; - ability (have or not have) –
checkAbility; - power and toughness –
checkPT; - permanent count –
checkPermanentCount; - hand count –
checkHandCount; - graveyard count;
- damage
- exile count;
- command zone count;
- counters count;
- mana pool;
- player life;
Other:
- add “resolve” command to wait stack resolving in same step (cast 1, resolve, cast 2);
Code example with real time checks:
public void test_DaxosGotBoostAndSaveColor() {
addCard(Zone.HAND, playerA, daxosCard, 1);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
//
addCard(Zone.HAND, playerA, "Chaoslace", 1); // Target spell or permanent becomes red.
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
//
addCard(Zone.HAND, playerA, "Archetype of Courage", 1); // Enchantment to trigger Daxos
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
// dax cast
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, daxosCard);
checkPermanentCount("dax exist", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, daxosCard, 1);
checkColor("dax without color", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, daxosCard, "R", false);
// give dax new color
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Chaoslace", daxosCard);
checkPT("dax not boost", 3, PhaseStep.BEGIN_COMBAT, playerA, daxosCard, 0, 0);
checkColor("dax is red", 3, PhaseStep.BEGIN_COMBAT, playerA, daxosCard, "R", true);
// color is saved on boost
castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, "Archetype of Courage"); // make dax to creature
checkPT("dax boost", 5, PhaseStep.BEGIN_COMBAT, playerA, daxosCard, 5, 5);
checkAbility("dax fly", 5, PhaseStep.BEGIN_COMBAT, playerA, daxosCard, FlyingAbility.class, true);
checkColor("dax is red", 5, PhaseStep.BEGIN_COMBAT, playerA, daxosCard, "R", true);
setStopAt(5, PhaseStep.END_TURN);
execute();
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Assertions In Selenium Using Junit And TestNG Frameworks
Assertions are used to perform various kinds of validations in the test cases, which in turn helps us to decide whether the test...
Read more >How To Use Assertions In TestNG With Selenium - LambdaTest
In this TestNG tutorial, you will learn how to use different assertions in TestNG and see how they are helpful in Selenium automation...
Read more >Assert and Verify Methods in Selenium | BrowserStack
Understand the difference between assert and verify in Selenium with command examples to execute types of Assert methods.
Read more >How To Use TestNG Asserts with Selenium To ... - Tools QA
Since we are now well versed with all the significant concepts in TestNG, it is time to execute some actual tests using selenium...
Read more >Python's assert: Debug and Test Your Code Like a Pro
In practice, you can use assertions to check preconditions and postconditions in your programs at development time. For example, programmers ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

https://github.com/magefree/mage/blob/e1cf2fd7e077ae9a3e9dd9694e3cede923546631/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java#L289
Feel free to enable, and add a PR.
I am working on enabling
assertAllCommandsUsed. The reason it’s not enabled is since many tests have errors that need fixing. (it was added after the tests were written).The
setStrictChooseModeis not needed for all tests since some choices are okay for the AI to autochoose (e.g only one option available).