示例#1
0
  @Test
  public void setInvalidYPositionTest() {
    int y = -1;
    String failureMessage = "Expected exception message is not corrected.\n";
    try {
      position.setY(y);
    } catch (Exception e) {
      String expectedErrorMessage =
          "Ivalid position: The " + "y position " + y + " is not a valid position.";

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

      System.out.println("Test for y = " + y + " : Test ok Expected an " + "exception.");
    }

    y = -10;
    try {
      position.setY(y);
    } catch (Exception e) {
      String expectedErrorMessage =
          "Ivalid position: The " + "y position " + y + " is not a valid position.";

      TestCase.assertEquals(failureMessage, expectedErrorMessage, e.getMessage());
      System.out.println("Test for y = " + y + " : Test ok Expected an " + "exception.");
    }
  }
示例#2
0
  @Test
  public void setValidYPositionTest() {
    int y = 6;
    try {
      position.setY(y);
      TestCase.assertEquals(y, position.getY());
      System.out.println("Test for y = " + y + " : Test ok. Valid value.");

    } catch (Exception e) {

      TestCase.fail();
    }

    y = 1;
    try {

      position.setY(y);
      TestCase.assertEquals(y, position.getY());
      System.out.println("Test for y = " + y + " : Test ok. Valid value.");

    } catch (Exception e) {

      TestCase.fail();
    }
  }