Added unit tests for Java, JavaScript and JSON mods

This commit is contained in:
Anuken
2021-06-12 20:59:28 -04:00
parent d6016f1b04
commit 347b38ba26
20 changed files with 587 additions and 397 deletions

View File

@@ -0,0 +1,39 @@
import arc.util.*;
import mindustry.*;
import mindustry.gen.*;
import mindustry.type.*;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
//grabs a version-locked Heavy Armaments Industries commit and makes sure it initializes correctly
//this mod was chosen because:
//- it is one of the top JS mods, based on stars
//- it contains both JS and JSON, which can be used to test compatibility of the two
//- it can be used server-side (unlike FactoryDustry, which is a client-side texture pack that cannot be tested here)
public class ModTestHAI extends GenericModTest{
@Test
public void begin(){
grabMod("https://github.com/Eschatologue/Heavy-Armaments-Industries/archive/d996e92dcf9a30a6acb7b3bfdfb6522dddc3804c.zip");
checkExistence("heavy-armaments");
UnitType type = Vars.content.units().find(u -> u.name.equals("heavy-armaments-t3A_copter"));
assertNotNull(type, "A mod unit must be loaded.");
assertTrue(type.weapons.size > 0, "A mod unit must have a weapon.");
Vars.world.loadMap(ApplicationTests.testMap);
Unit unit = type.spawn(0, 0);
//check for crash
unit.update();
assertTrue(unit.health > 0, "Unit must be spawned and alive.");
assertTrue(Groups.unit.size() > 0, "Unit must be spawned and alive.");
//just an extra sanity check
Log.info("Modded units: @", Vars.content.units().select(u -> u.minfo.mod != null));
}
}