Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-06T13:48:07.000Z (3 months ago)
- Last Synced: 2024-10-15T17:24:00.807Z (3 months ago)
- Topics: java, pojo, pojo-tester, pojo-testing
- Language: Java
- Homepage:
- Size: 395 KB
- Stars: 0
- Watchers: 2
- 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
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)
![GitHub release](https://img.shields.io/github/v/release/fabasoad/pojo?include_prereleases)
![unit-tests](https://github.com/fabasoad/pojo/actions/workflows/unit-tests.yml/badge.svg)
![security](https://github.com/fabasoad/pojo/actions/workflows/security.yml/badge.svg)
![linting](https://github.com/fabasoad/pojo/actions/workflows/linting.yml/badge.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/fabasoad/pojo/badge.svg)](https://snyk.io/test/github/fabasoad/pojo)## 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
```xml
io.fabasoad
pojo
0.2.1```
## 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()
}
}
```