io.github.fssantana:unit-mock

A tool to create filled instances mocks for unit testing purpose.

License

License

BSD
Categories

Categories

Ant Build Tools
GroupId

GroupId

io.github.fssantana
ArtifactId

ArtifactId

unit-mock
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

io.github.fssantana:unit-mock
A tool to create filled instances mocks for unit testing purpose.
Project URL

Project URL

https://github.com/fssantana/unit-mock
Project Organization

Project Organization

jcabi.com
Source Code Management

Source Code Management

http://github.com/fssantana/unit-mock/tree/master

Download unit-mock

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.fssantana/unit-mock/ -->
<dependency>
    <groupId>io.github.fssantana</groupId>
    <artifactId>unit-mock</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.fssantana/unit-mock/
implementation 'io.github.fssantana:unit-mock:1.0.0'
// https://jarcasting.com/artifacts/io.github.fssantana/unit-mock/
implementation ("io.github.fssantana:unit-mock:1.0.0")
'io.github.fssantana:unit-mock:jar:1.0.0'
<dependency org="io.github.fssantana" name="unit-mock" rev="1.0.0">
  <artifact name="unit-mock" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.fssantana', module='unit-mock', version='1.0.0')
)
libraryDependencies += "io.github.fssantana" % "unit-mock" % "1.0.0"
[io.github.fssantana/unit-mock "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.6.1

test (3)

Group / Artifact Type Version
org.mockito : mockito-core jar 2.21.0
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

Unit Mock


Build Status

Set of tools to help build mocks for unit testing purpose.

Usage

  • Use methods in UnitMock class to create simple mocks:
public class TestExample {

    @Test
    public void testLocalDate(){
        LocalDate localDate = UnitMock.localDate();
    }
    
    @Test
    public void testLocalDateTime(){
        LocalDate localDate = UnitMock.localDateTime();
    }
}
  • You can build an filled instance like this:
public class TestExample {

    @Test
    public void test(){
        MyClass myInstance = UnitMock.buildFor(MyClass.class);
    }
    
    /**
    * This will fill all subclasses with 10 depth 
    */
    @Test
    public void testInDepth(){
        MyClass myInstance = UnitMock.buildFor(MyClass.class, 10);
    }
    
}
  • You can mock incremental integer (like a relational database)
public class TestExample {
    
    @Test
    public void integerSequenceTest(){
    UnitMockIntegerSequence sequence = UnitMockIntegerSequence
                    .init()
                    .startWith(0)
                    .incrementStep(2)
                    .build();
    
            Integer firstId = sequence.next();   //0
            Integer secondId = sequence.next();  //2
            Integer thirdId = sequence.next();   //4
    }
}

Versions

Version
1.0.0