I need to use JUnit to test a few methods I have written. When I go to create a test class and write a test method, IntelliJ runs the entire program (including the main method) which is not finished. I want only to test a single method and for that, I've done as the instructions say (Ctrl+Shift+F10) or the little green Play button near the method if you will. Still, It always runs the entire code and gives me errors not regarding the method I want to test.
class QueensTest {
@Test
void testCreate() {
assertNotNull(Queens.create(4));
assertThrows(IllegalArgumentException.class, () -> Queens.create(-1));
}
}
This is the method I want to test, and it gives me this error.
java: cannot find symbol
symbol: variable TODO
location: class at.jku.ssw.queens.app.QueensMain
If it would help I could post the entire code (all of the classes).
The code that causes the error:
public static void main(String[] args) throws Exception {
Out.print("Waehle Groesse: ");
int n = In.readInt();
Queens game = TODO;
Out.println();
printBoard(game);
boolean terminate = false;
while (TODO) {
Out.println();
Out.print("Waehle Setzen (S) | Entfernen (E) | Clear (C) | Quit (Q): ");
char cmd = Character.toUpperCase(In.readChar());
if (cmd == 'S') {
Out.print("Setze Queen auf Zeile: ");
int row = In.readInt();
Out.print(" Spalte: ");
char col = Character.toUpperCase(In.readChar());
// TODO
} else if (cmd == 'E') {
Out.print("Entferne Queen von Zeile: ");
int row = In.readInt();
Out.print(" Spalte: ");
char col = Character.toUpperCase(In.readChar());
// TODO
} else if (cmd == 'C') {
// TODO
} else if (cmd == 'Q') {
terminate = true;
} else {
Out.println("Ungueltiges Kommando!");
}
}
}
private static void printBoard(Queens game) throws Exception {
Out.print(" |");
for (int col = 0; col < game.getSize(); col++) {
Out.print(String.format(" %c ", (char)('A' + col)));
}
Out.println("|");
Out.print("---|");
for (int col = 0; col < game.getSize(); col++) {
Out.print("---");
}
Out.println("|");
for (int row = 1; row <= game.getSize(); row++) {
Out.print(String.format(" %d |", row));
for (int col = 0; col < game.getSize(); col++) {
Out.print(TODO ? " Q " : " . ");
}
Out.println("|");
}
Out.print("---|");
for (int col = 0; col < game.getSize(); col++) {
Out.print("---");
}
Out.println("|");
Out.println();
Out.println("Stand: " + TODO);
}