jdummy

Jdummy is the simplest library for creating test objects

License

License

GroupId

GroupId

com.github.nmuzhichin
ArtifactId

ArtifactId

jdummy
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

jdummy
Jdummy is the simplest library for creating test objects
Project URL

Project URL

https://github.com/nmuzhichin/jdummy
Source Code Management

Source Code Management

https://github.com/nmuzhichin/jdummy

Download jdummy

Dependencies

runtime (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.30

Project Modules

There are no modules declared in this project.

About Jdummy

Jdummy is the simplest library for creating test objects.

Jdummy provides capabilities:

  • creation of complex objects
  • protection against cyclic object instantiation
  • fields' modifiers for more logical and contextual values
  • creation and populate of collections

Easy to use:

Just call Jdummy.of(..)

class VeryBoringTest {
    // for example a service that doesn't like nullable fields in POJO
    private NullfobicService nullfobicService = new NullfobicService();
    
    void testNullphobicService() {
        User user = Jdummy.of(User.class); // all fields will be present
        Assertions.assertDoesNotThrow(() -> nullfobicService.save(user));
    }
}

or use junit5 extension

@ExtendWith(JdummyExtension.class)
class JdummyExtensionTest {

    @Test
    @JdummySource
    void generateInteger(Integer value) {
        Assertions.assertNotNull(value, "Value must be generated");
    }
}

Download

Maven

<dependency>
    <groupId>com.github.nmuzhichin</groupId>
    <artifactId>jdummy-core</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>
<!-- For junit-jupiter extension -->
<dependency>
    <groupId>com.github.nmuzhichin</groupId>
    <artifactId>jdummy-junit5</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>

Gradle

testImplementation 'com.github.nmuzhichin:jdummy-core:1.1.0'
// For junit-jupiter extension
testImplementation 'com.github.nmuzhichin:jdummy-junit5:1.1.0'

Advanced features

Cache

If you need to use a ready-made object to create an instance, just call Jdummy.putCache (...) before that.

Custom modifiers

Each subject area has its own characteristics, which can be reflected in the names of the fields and their values.

For this, Jdummy contains a ValueModifier type that is used to customize the values. You can declare your own ValueModifier type and write it to a custom META-INFO/services/com.github.nmuzhichin.jdummy.modifier.ValueModifier for loading by ServiceLoader.

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.0