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

#68 - API implementation #76

Conversation

sta-szek
Copy link
Owner

@sta-szek sta-szek commented Sep 8, 2016

So here it is. Sample usage with custom testing configuration:

assertPojoMethodsFor(stringClass).using(fieldValueChanger)
                                 .testing(EQUALS)
                                 .testing(HASH_CODE)
                                 .testing(SETTERS_AND_GETTERS)
                                 .testing(TO_STRING)
                                 .areWellImplemented();

assertPojoMethodsFor(stringClass, fieldPredicate).using(fieldValueChanger)
                                                 .testing(EQUALS, HASH_CODE, SETTERS_AND_GETTERS, TO_STRING)
                                                 .areWellImplemented();

assertPojoMethodsFor(classAndFieldPredicatePair).using(fieldValueChanger)
                                                .testing(EQUALS, HASH_CODE, SETTERS_AND_GETTERS, TO_STRING)
                                                .areWellImplemented();

assertPojoMethodsFor(classAndFieldPredicatePair, classAndFieldPredicatePair).using(fieldValueChanger)
                                                                            .testing(EQUALS, HASH_CODE, SETTERS_AND_GETTERS, TO_STRING)
                                                                            .areWellImplemented();

assertPojoMethodsForAll(stringClass, stringClass).using(fieldValueChanger)
                                                 .testing(EQUALS, HASH_CODE, SETTERS_AND_GETTERS, TO_STRING)
                                                 .areWellImplemented();

assertPojoMethodsForAll(classAndFieldPredicatePair, classAndFieldPredicatePair).using(fieldValueChanger)
                                                                               .testing(EQUALS, HASH_CODE, SETTERS_AND_GETTERS, TO_STRING)
                                                                               .areWellImplemented();

and in the simplest way, where all fields of your class A should be tested with all testers:
assertPojoMethodsFor(A.class).areWellImplemented();

Implemented in hurry, so you can make a good code review ;)

@@ -40,23 +40,32 @@ private void testSetterAndGetter(final SetterAndGetterPair eachPair, final Objec
final Object newValue = objectGenerator.createNewInstance(fieldType);

try {
assertions.assertThatSetMethodFor(instance)
.willSetValueOnField(setter, field, newValue);
if (setter != null) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hasSetter method is better for testing setter :)

@sta-szek sta-szek merged commit 35857ec into master Sep 11, 2016
@sta-szek sta-szek deleted the #68-Find-out-the-most-user-friendly-pojo-tester-api-for-testing branch September 11, 2016 08:04
@sta-szek sta-szek self-assigned this Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants