Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TestNG with Junit #4942

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions forge-game/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<artifactId>forge-game</artifactId>
<name>Forge Game</name>

<properties>
<junit.version>5.10.1</junit.version>
</properties>

<dependencies>
<dependency>
<groupId>forge</groupId>
Expand All @@ -24,9 +28,9 @@
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
12 changes: 8 additions & 4 deletions forge-game/src/test/java/forge/game/ability/AbilityKeyTest.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package forge.game.ability;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;

import org.junit.jupiter.api.Test;

import com.google.common.collect.Maps;


public class AbilityKeyTest {

@Test
public void testFromStringWorksForAllKeys() {
for (AbilityKey key : AbilityKey.values()) {
AssertJUnit.assertEquals(key, AbilityKey.fromString(key.toString()));
assertEquals(key, AbilityKey.fromString(key.toString()));
}
}

Expand All @@ -21,6 +25,6 @@ public void testCopyingEmptyMapWorks() {
Map<AbilityKey, Object> newMap = AbilityKey.newMap(map);

// An actual copy should be made.
AssertJUnit.assertNotSame(map, newMap);
assertNotSame(map, newMap);
}
}
28 changes: 13 additions & 15 deletions forge-game/src/test/java/forge/game/mana/ManaCostBeingPaidTest.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
package forge.game.mana;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import static forge.card.MagicColor.COLORLESS;
import static forge.card.MagicColor.GREEN;
import static forge.card.MagicColor.RED;
import static forge.card.MagicColor.WHITE;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostParser;

public class ManaCostBeingPaidTest {

@Test
public void testPayManaViaConvoke() {
runConvokeTest("1 W W", new byte[] { WHITE, COLORLESS, WHITE }, new String[] { "{1}{W}{W}", "{1}{W}", "{W}" });
runConvokeTest("1 W W", new byte[] { COLORLESS, WHITE, WHITE }, new String[] { "{1}{W}{W}", "{W}{W}", "{W}" });
runConvokeTest("1 W W", new byte[] { GREEN, WHITE, WHITE }, new String[] { "{1}{W}{W}", "{W}{W}", "{W}" });
runConvokeTest("1 W G", new byte[] { GREEN, RED, WHITE }, new String[] { "{1}{W}{G}", "{1}{W}", "{W}" });
runConvokeTest("1 W W", new byte[]{WHITE, COLORLESS, WHITE}, new String[]{"{1}{W}{W}", "{1}{W}", "{W}"});
runConvokeTest("1 W W", new byte[]{COLORLESS, WHITE, WHITE}, new String[]{"{1}{W}{W}", "{W}{W}", "{W}"});
runConvokeTest("1 W W", new byte[]{GREEN, WHITE, WHITE}, new String[]{"{1}{W}{W}", "{W}{W}", "{W}"});
runConvokeTest("1 W G", new byte[]{GREEN, RED, WHITE}, new String[]{"{1}{W}{G}", "{1}{W}", "{W}"});
}

private void runConvokeTest(String initialCost, byte[] colorsToPay, String[] expectedRemainder) {
ManaCostBeingPaid costBeingPaid = createManaCostBeingPaid(initialCost);

for (int i = 0; i < colorsToPay.length; i++) {
AssertJUnit.assertEquals(expectedRemainder[i], costBeingPaid.toString());
assertEquals(expectedRemainder[i], costBeingPaid.toString());
costBeingPaid.payManaViaConvoke(colorsToPay[i]);
}

AssertJUnit.assertEquals("0", costBeingPaid.toString());
assertEquals("0", costBeingPaid.toString());
}

private ManaCostBeingPaid createManaCostBeingPaid(String costString) {
ManaCostParser parsedCostString = new ManaCostParser(costString);
ManaCost manaCost = new ManaCost(parsedCostString);

return new ManaCostBeingPaid(manaCost);
private ManaCostBeingPaid createManaCostBeingPaid(String cost) {
ManaCostParser parser = new ManaCostParser(cost);
return new ManaCostBeingPaid(new ManaCost(parser));
}
}
Loading