Browse Source
DTSUD-47 - added test framework in maven and worte test for setupField and implemented gameField.
remotes/origin/develop
DTSUD-47 - added test framework in maven and worte test for setupField and implemented gameField.
remotes/origin/develop
fdai6499
2 years ago
3 changed files with 119 additions and 1 deletions
@ -0,0 +1,48 @@ |
|||
import org.junit.Test; |
|||
|
|||
import javax.swing.*; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
class MainTest extends Main { |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void testField() { |
|||
|
|||
JPanel setupGameField = setupGameField(360); |
|||
|
|||
JLabel[][] labelField = getLabelField(); |
|||
|
|||
for (int i = 0; i < 9; i++) { |
|||
for (int j = 0; j < 9; j++) { |
|||
labelField[i][j].setText(String.valueOf(j)); |
|||
} |
|||
} |
|||
|
|||
boolean a = true; |
|||
|
|||
for (int i = 0; i < 9; i++) { |
|||
for (int j = 0; j < 9; j++) { |
|||
String s = labelField[i][j].getText(); |
|||
try { |
|||
Integer integer = Integer.valueOf(s); |
|||
if (j != integer) { |
|||
a = false; |
|||
} |
|||
} catch (NumberFormatException e) { |
|||
assertTrue(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
assertTrue(a); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void testBla() { |
|||
assertTrue(true); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue