forked from External/mage
Extra tests to catch card creation errors;
This commit is contained in:
parent
e77b21f4e9
commit
b9b8415c99
3 changed files with 43 additions and 6 deletions
|
|
@ -15,6 +15,7 @@ import mage.game.draft.RateCard;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -41,6 +42,8 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class VerifyCardDataTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(VerifyCardDataTest.class);
|
||||
|
||||
// right now this is very noisy, and not useful enough to make any assertions on
|
||||
private static final boolean CHECK_SOURCE_TOKENS = false;
|
||||
|
||||
|
|
@ -971,4 +974,28 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCardsCreatingAndConstructorErrors() {
|
||||
int errorsCount = 0;
|
||||
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||
for (ExpansionSet set : sets) {
|
||||
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
||||
// catch cards creation errors and report (e.g. on wrong card code or construction checks fail)
|
||||
try {
|
||||
Card card = CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()));
|
||||
if (card == null) {
|
||||
errorsCount++;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error("Can't create card " + setInfo.getName() + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errorsCount > 0) {
|
||||
Assert.fail("Founded " + errorsCount + " broken cards, look at logs for stack error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue