コード例 #1
0
ファイル: PositionTest.java プロジェクト: Ratchette/Checkers
  @Test
  public void setValidXPositionTest() {
    int x = 5;
    String failureMessage = "Expected exception message is not corrected.\n";
    try {
      position.setX(x);
      TestCase.assertEquals(x, position.getX());
      System.out.println("Test for x = " + x + " : Test ok. Valid value.");

    } catch (Exception e) {

      String expectedErrorMessage =
          "Ivalid position: The " + "x position " + x + " is not a valid position.";

      TestCase.assertEquals(failureMessage, expectedErrorMessage, e.getMessage());
    }

    x = 2;
    try {

      position.setX(x);
      TestCase.assertEquals(x, position.getX());
      System.out.println("Test for x = " + x + " : Test ok. Valid value.");

    } catch (Exception e) {

      String expectedErrorMessage =
          "Ivalid position: The " + "x position " + x + " is not a valid position.";

      TestCase.assertEquals(failureMessage, expectedErrorMessage, e.getMessage());
    }
  }