How to unit test getters and setters in Java

H

It is possible to test getters and setters (properties) from your model class. Through a test class, it is done in no time.

In the test class of your model class, you add the following code:

@Test
public void testGettersSetters() {
    PropertyAsserter.assertBasicGetterSetterBehavior(new ModelClassToTest());
}

ModelClassToTest = your class name you want to test

Download the source code here: [wpdm_file id=1]

Add comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tag Cloud

Categories

%d bloggers like this: