テストの 1 つが失敗する理由がわかりません。
テストは次のとおりです。
@Test(expected = IllegalArgumentException.class)
public void complainsIfFromLocIsDifferentObject() throws Throwable {
    board.set(make(), 1, 3); //Creates different rook from 'piece'
    assertFalse("ChessPiece Test 2", piece.isValidMove(getValidMove(1, 3), board));
}
ブレークポイントを設定し、プロセスを複数回実行しました。クラスの 2 番目の if ステートメントに入りChessPiece、例外がスローされるようです。その後、プロセスはクラスに戻り、ブロックRookの下で false を返します。super
何が起こっているかについてのアイデアはありますか?ありがとう
関連コード:
public class Rook extends ChessPiece {
    @Override
    public boolean isValidMove(Move m, IChessBoard b) {
        if (super.isValidMove(m, b) == false)
            return false;
        // Add logic specific to rook
        if(m.fromRow == m.toRow || m.fromColumn == m.toColumn)
            return true;
        else 
            return false;
    }
}
public abstract class ChessPiece implements IChessPiece {
    @Override
    public boolean isValidMove(Move m, IChessBoard b) {
        //Verify that there is a piece at the origin
        if (b.pieceAt(m.fromRow,m.fromColumn) == null)
            throw new IllegalArgumentException();
        // Verify that this piece is located at move origin
        IChessPiece piece = b.pieceAt(m.fromRow, m.fromColumn);
        if (this != piece)
            throw new IllegalArgumentException();
     }
}