Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fabasoad/pojo

Open more actions menu

Repository files navigation

POJO testing library

Stand With Ukraine GitHub release unit-tests security linting

Import

  1. Add GitHub Packages maven server to pom.xml
  2. Import pojo dependency.

Maven

See example on how to use it with maven.

Examples

Java

public class PojoTest {
  // The package to test
  private static final String PACKAGE_NAME = "io.fabasoad.pojo";

  @Test
  public void testPojoStructureAndBehavior() {
    final PojoValidator validator = PojoValidatorBuilder.create(PACKAGE_NAME)
        .with(new GettersTester(new GettersMustExistRule()))
        .with(new FieldsTester(
            new FieldsMustBeFinalRule(),
            new FieldsMustBePrivateRule()))
        .build();

    validator.validate();
  }
}

Groovy

class PojoSpec extends Specification {
  // The package to test
  def PACKAGE_NAME = "io.fabasoad.pojo";

  def "Getters and fields must follow the rules"() {
    given:
    def builder = PojoValidatorBuilder.create(PACKAGE_NAME)

    when:
    def validator = builder
        .with(new GettersTester(new GettersMustExistRule()))
        .with(new FieldsTester(
            new FieldsMustBeFinalRule(),
            new FieldsMustBePrivateRule()))
        .build()

    then:
    validator.validate()
  }
}

Contributions

Alt

About

POJO testing library that help you to avoid boilerplate code to test your POJO classes

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.