Skip to content

fssantana/unit-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages