Assert - Tki-sor/UtilJS GitHub Wiki
Hmm, through UtilJS.asserts
you can use customized test methods, roughly like this: used to check if your expected value matches the actual value. If they don’t match, an exception is thrown directly. But don’t worry, kubejs won’t cause the game to crash — feel free to use it (?
The following methods are provided (may change in the future?):
// T refers to any type, for example if you input a String, then T is String
public <T> T assertNotNull(T value);
public <T> T assertNotNull(T value, String message);
public <T> T requireNotNull(T value);
public <T> T requireNotNull(T value, String message);
public <T> T requireNotNull(T value, Supplier<String> lazyMessage);
public void assertTrue(boolean condition);
public void assertTrue(boolean condition, String message);
public void assertFalse(boolean condition);
public void assertFalse(boolean condition, String message);
public <T> void assertEquals(T expected, T actual);
public <T> void assertNotEquals(T unexpected, T actual);
public void assertNull(Object obj);
// Directly throw an assertion exception
public void fail();
public void fail(String message);
Please ensure your debug code does not run in the production release. Currently, this mod does not have a Test framework; these methods are only for testing purposes.