[General boards] [Winter 2019 courses] [Fall 2018 courses] [Summer 2018 courses] [Older or newer terms]



one of my tests is like this in Fishtest class:

public void testBubbleCreated() {

    fish.setLocation(2, 10);


    assertTrue(FishTank.getEntity(2, 10) instanceof Bubble);

it passes like expected because there is nothing at (2, 10) originally but

protected void blowBubble() {
Bubble b = new Bubble();
b.setLocation(x, y);
System.out.println(x + " " + y);

        if (FishTank.getEntity(x, y) == null || FishTank.getEntity(x, y) instanceof Bubble) {
            FishTank.addEntity(x, y, b);


my blowbuuble is like that^. If I only reverse the coordinates in (b.setlocation) then it will still pass because of the other lines when its not supposed to. So when your testing can I assume you would reverse the coordinates on all lines or?


I don’t really understand the question, could you elaborate on


can I assume you would do:

Bubble b = new Bubble();
b.setLocation(y, x);
System.out.println(x + " " + y);

        if (FishTank.getEntity(y, x) == null || FishTank.getEntity(y, x) instanceof Bubble) {
            FishTank.addEntity(y, x, b);

and not just flip the coordinates on b.setlocation(y, x)?


Our tests will use (x, y) always – that’s the semantics of setLocation (its parameter names are x, y), similarly, addEntity’s parameter names are (x, y)


yes but when you replace our code with a buggy implementation


There are no guarantees about the buggy implementation, except for it will do “unreasonable” things that should obviously be bugs