mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Added unit tests for Java, JavaScript and JSON mods
This commit is contained in:
parent
d6016f1b04
commit
347b38ba26
20 changed files with 587 additions and 397 deletions
40
tests/src/test/java/ModTestExotic.java
Normal file
40
tests/src/test/java/ModTestExotic.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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 exotic-mod commit and makes sure its content is parsed correctly
|
||||
//this mod was chosen because:
|
||||
//- it is written solely in (h)json
|
||||
//- it is probably the mod with the most json, and as such covers a lot of classes
|
||||
//- it is popular enough in the mod browser
|
||||
//- I am somewhat familiar with its files & the type of content it adds
|
||||
public class ModTestExotic extends GenericModTest{
|
||||
|
||||
@Test
|
||||
public void begin(){
|
||||
grabMod("https://github.com/BlueWolf3682/Exotic-Mod/archive/08c861398ac9c3d1292132f9a110e17e06294a90.zip");
|
||||
checkExistence("exotic-mod");
|
||||
|
||||
UnitType type = Vars.content.units().find(u -> u.name.equals("exotic-mod-luminance"));
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue