BuildCraft|Core

BuildCraft|Core

7M Downloads

Add unit tests

SoniEx2 opened this issue ยท 9 comments

commented

Self-explanatory.

commented

Soni, pls, you're tempting me to make a MC unit testing framework

commented

Dream on, Soni. Dream on.

Minecraft has no testing framework for us to utilize.

commented

I know.

I can do IInventory testing at least...

commented

Krapht already did some of it in an ancient repo.

commented

To unittest inventories is pretty simple:

List<IInventory> allInvs = new ArrayList<IInventory>();

public void init() {
    IInventory myInventory = new MyInventory();
    allInvs.add(myInventory);
    // repeat for the other invs
}

public void testGetStackInSlotOnClosing() {
    // fill invs
    for (IInventory inv : allInvs) {
        for (int i = 0, j = inv.getSizeInventory(); i<j; i++) {
            inv.setInventorySlotContents(i, new ItemStack(...)); // put something here
        }
    }
    // test
    for (IInventory inv : allInvs) {
        for (int i = 0, j = inv.getSizeInventory(); i<j; i++) {
            ItemStack expected = inv.getStackInSlot(i);
            ItemStack got = inv.getStackInSlotOnClosing(i);
            if (expected != got) throw new RuntimeException();
            if (inv.getStackInSlot(i) != null) throw new RuntimeException();
        }
    }
}

(Not the actual code you'd use but it gives you an idea)

commented

Yeah I've looked into it and its basically not gonna happen.

commented

A world full of unit tests?

commented

feel free to make us one

commented

are we still adding unit tests? 99.99% of BC can't realy be tested that way