#Tough one: making unit test framework to test basic stuff during PR checks

1 messages · Page 1 of 1 (latest)

distant slate
#

Tough one: making unit test framework to test basic stuff during PR checks

distant slate
#

.

vague oyster
#

I have done some work on this, and so far have it creating a test world and then generating a structure defined in a json in the world, so that it can run for X ticks and read the world.

#

The NBT of each block (if it has any) is encoded into a string and decoded later back into a usable state. You can see this from the "encodedNBT" field

#

We can see in the instructions section, it has the following info

  "instructions": [
    {
      "type": "addItems",
      "optionalLabel": "Adds an item to the inventory of the block.",
      "x": 0,
      "y": 0,
      "z": 2,
      "items": [
        {
          "registryName": "bartworks:gt.bwMetaGenerateddust",
          "stackSize": 1,
          "metadata": 11037
        }
      ]
    },
    {
      "type": "runTicks",
      "duration": 1000
    },
    {
      "type": "checkTile",
      "optionalLabel": "OptionalIsSmelted",
      "x": 2,
      "y": 0,
      "z": 2,
      "funcRegistry": "ebfOutputCheck"
    }
  ]
#

This is three instructions.

The first being addItems, which adds an item to the block at the relative coordinates. This uses the IInventory interface to achieve this.

The second being runTicks, which progresses the world state by the number of ticks specified (this lets the recipe run).

Then the final is checkTile, this uses a function that must be registered using

        RegisterConditionals.conditionalRegister("ebfOutputCheck", TestConditional::isItemStackSizeOne);

This will then call the code here

    public static boolean ebfOutputCheck(TileEntity tile, World world) {
        return ((IInventory) tile).getStackInSlot(0).stackSize == 1;
    }

In this instance, it will check if the tile entity (so the output bus) has an itemstack at slot 0 of size 1, if the recipe has processed and succeded, then this will return true to validate the condition. It will then print to the log whether this condition passed, failed or threw an exception. We can see that instructions generally have an optionalLabel they can print, to give any extra insight to the developer. In this case:

[20:56:44] [Server thread/INFO] [STDOUT]: Procedure CheckTile with optionalLabel OptionalIsSmelted processed in tick 1003 on the server thread.
[20:56:44] [Server thread/INFO] [STDOUT]: OptionalIsSmelted PASSED
distant slate
#

.

distant slate
#

@vague oyster can you try to write here?

vague oyster
#

All good