-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add ignores to getter setter rules and testers #66
Comments
Take a look at pull request #90. I modified Setter/GetterTester to do it: SetterTester setterTester = new SetterTester(); By doing it, OpenPojo will skip setName test. I just realized that I should give another name to method, instead addField. It may lead to a inverse understanding of it's purpose... Meanwhile Oshoukry decided if he will incorporate it or not, I wrote my own Setter/Getter extending Tester interface. You could do it... |
oh we have, but seems like it should be core to the lib |
Hi, |
First of all thanks for the useful API. I also had the need to ignore fields (i would think this would be a common need). Being as #90 or something similar isn't making it into the codebase I implemented a solution that doesn't require a code change to openpojo. Here is how my implementation works...
The concept is to
Note in addition to working on Testers this approach can also be used on Rules. I'm sure there are other ways to do this too... |
@stevensouza - thanks for the workaround. It would be really nice to have something in the API itself, but like you say, until then we can use code similar to what you have. |
Note, if anyone is interested I can paste more of the code. I didn't because although |
Please publish your complete code as a GitHub Gist. Thanks. |
Is this dead? I have a POJO with a setter method that has special considerations. It may set true even if the input is false, depending on certain conditions. I cannot test setters of this class with OpenPojo. |
Here you go: https://gist.github.com/patrickhuy/0392c54f52ad921bcf0152fe3cbb4d7c this shows an example how such an exclude could be implemented. Note that it is a rather naive implementation and does not use caching or anything |
There's a few cases where sometimes i just want to ignore a specific field. I should be able to do that. This would be a solution to #48 as well.
I suggest adding vararg string params to the constructors of the tester to include a list of ignores. Or you could annotate a field with an annotation...but i don't want to decorate my class just for testing in general so i prefer making the rules/testers a little flexible.
The text was updated successfully, but these errors were encountered: