Hello!
Imagine, I have a piece of code, which returns different block types in different situations.
public class MyClass {
public BlockType calculateBlockType(final String input) {
BlockType result = null;
// Here I determine the result
return result;
}
}
Now I want to write an automated test, which verifies that this method returns the right block types.
I can’t write something like this:
@Test
public void calculateBlockType() {
final MyClass sut = new MyClass();
final BlockType blockType = sut.calculateBlockType("someInput");
Assert.assertEquals(blockType, BlockTypes.WATER)
}
According to IntelliJ IDEA, all constants in BlockTypes
are null.
package org.spongepowered.api.block;
/**
* An enumeration of all possible {@link BlockType}s in vanilla minecraft.
*/
public final class BlockTypes {
[...]
public static final BlockType WALL_SIGN = null;
public static final BlockType WATER = null;
public static final BlockType WATERLILY = null;
[...]
}
Therefore, I can’t tell WATER
apart from WALL_SIGN
, WATERLILY
or any other block type.
What is the right way to automatically test code, which operates on block types (apart from wrapping BlockType
into some class) ?
Thanks in advance
Dmitri Pisarenko