I'm just starting out with testing.
The method I'm trying to test has no return value (void), but it creates a static 2D array (char[][]) in its own class, so from what I understand, that is its side effect.
Here is some mock code:
public class MyClass{
public static char[][] table;
public void setTable(int rows, int columns, int number){
board = new char[n][m];
// more code that alters the table in a specific way,
// depending on the 3rd parameter
}
Now for the testing, I was thinking of doing something like:
public class SetTableTest{
@Test
public void test(){
MyClass test = new MyClass();
assertArrayEquals(**********, test.table);
}
}
I have 2 questions:
Am I allowed comparing to a static variable like I did (
test.table) ie. will that actually return an "instance" of the completed table?I'm fairly certain that there's no
assertArrayEqualsequivalent for 2D arrays, so how do I go about this?