Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getter-setter tests succeed despite of bugs #202

Open
36893488147419103231 opened this issue Aug 16, 2017 · 1 comment
Open

getter-setter tests succeed despite of bugs #202

36893488147419103231 opened this issue Aug 16, 2017 · 1 comment
Labels
Milestone

Comments

@36893488147419103231
Copy link
Contributor

36893488147419103231 commented Aug 16, 2017

In the project
https://github.com/36893488147419103231/pojo-tester-tester
there is a number of classes with buggy getters and setters.

The bugs that are not detected are shown below (the code without bugs is omitted):

public class Bad4b {
  int qp;
  int db;
  public void setDb(int db) {
    this.db = qp; // bug
  }
}
public class Bad3a {
  int qp;
  int db;
  public int getQp() {
    return db; // bug
  }
  public int getDb() {
    return qp; // bug
  }
}
public class Bad2c {
  int qp;
  int db;
  public int getDb() {
    return qp; // bug
  }
}
public class Bad2a {
  int qp;
  int db;
  public int getQp() {
    return db; // bug
  }
}

In practice the bugs of this sort occur as a result of human error in copied&pasted code.

The problem with pojo-tester is that it tests getters when the object is filled with nulls. If all fields are set to null (or 0), whatever field you read from, you will get null.

The test of Bad4b succeeds most likely because the same value is passed to different setters. The difference between the tests of Bad4a and Bad4b is only in the order in which buggy and not-buggy setters are called; bad4aTest fails (which is ok), while bad4bTest succeeds (which is wrong).

@sta-szek sta-szek added the bug label Aug 17, 2017
@sta-szek sta-szek added this to the 1.0.0 milestone Aug 17, 2017
@sta-szek
Copy link
Owner

Thanks for reporting.
@36893488147419103231 would you like to fix this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants