https://github.com/fabasoad/pojo
POJO testing library that help you to avoid boilerplate code to test your POJO classes
https://github.com/fabasoad/pojo
java pojo pojo-tester pojo-testing
Last synced: 3 months ago
JSON representation
POJO testing library that help you to avoid boilerplate code to test your POJO classes
- Host: GitHub
- URL: https://github.com/fabasoad/pojo
- Owner: fabasoad
- License: mit
- Created: 2021-08-08T09:11:59.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-03T22:03:22.000Z (3 months ago)
- Last Synced: 2025-04-10T01:06:10.013Z (3 months ago)
- Topics: java, pojo, pojo-tester, pojo-testing
- Language: Java
- Homepage:
- Size: 456 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# POJO testing library
[](https://stand-with-ukraine.pp.ua)



## Import
1. Add [GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages)
maven server to `pom.xml`
2. Import `pojo` dependency.### Maven
[Here](https://github.com/fabasoad/pojo/packages/931918) is an example on how to
use it with maven.## Examples
### Java
```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
```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
