-
Notifications
You must be signed in to change notification settings - Fork 0
1. Introduction
This framework is built by keeping flexibility in mind. It has only byte buddy as a runtime dependency. A developer is not forced to use any specific testing framework (like JUnit, TestNG, etc.) and need to write a minimum number of line of code to achieve a greater result. In other words little boilerplate code for unit testing. Below is an example of unit testing code.
@Before
public void setup() {
assertObjectCreator = new AssertObjectCreator();// same as "new AssertObjectCreator(false);"
}
@Test
public void testMyClassTest01() {
String []packagesToBeScanned = {"org.pojotester.testing.mypack.dto.Test01.class"};
List<AssertObject<?>> assertObjects = assertObjectCreator.getAssertObjects(packagesToBeScanned);
assertFalse(assertObjects.isEmpty());
for(AssertObject<?> assertObject : assertObjects) {
assertEquals(assertObject.getClassFieldName(),
assertObject.getExpectedValue(), assertObject.getReturnedValue());
}
}
The above code will load Test01 class for unit testing and return assert objects for verifications.
In subsequent pages, I will be explaining you about how you could define the packages, which AssertionObjectCreator constructor should be used, how to use class level annotations to ignore/mark a class for testing, how to use field level annotations to ignore or define custom values for unit testing, and how to use method level annotations to define an object creator method or map read (getter) / write (setter) method with the field to meet your requirement.