-
Notifications
You must be signed in to change notification settings - Fork 0
3. Classes
There are several ways to use this framework based on the developer's requirement.
If the majority of the classes need to be tested in this package then the developer should use below mention object creator.
AssertObjectCreator assertObject = new AssertObjectCreator();
OR
// AssertObjectCreator assertObject = new AssertObjectCreator(false); Deprecated
AssertObjectCreator assertObject = new AssertObjectCreator();
In this scenario, all the class will be loaded for unit testing and if the developer wants to ignore any class from this package then it could be done using @IgnoreClass annotation at the class level.
org.pojotester.testing.mypack.dto
|- Test01
|- Test02
|- Test03 <@IgnoreClass>
|- Test04
|- Test05
Test01, Test02, Test04 and Test05 classes will be loaded and Test03 will be ignored.
If the selected class needed to be unit tested in a package then the developer should use below mention object creator.
// AssertObjectCreator assertObject = new AssertObjectCreator(true); Deprecated
AssertObjectCreator assertObject = new AssertObjectCreator();
assertObject.doLoadClassesAskedFor();
In this scenario, only classes which are marked as @TestThisClass annotation at class level will be loaded for unit testing.
org.pojotester.testing.mypack.dto
|- Test01 <@TestThisClass>
|- Test02
|- Test03 <@TestThisClass>
|- Test04
|- Test05
Test01 and Test03 classes will be loaded and Test02, Test04 & Test05 will be ignored.
If developer do not want to test overridden equals method.
assertObject.doNotTestEqualsMethod();
If developer do not want to test overridden hashCode method.
assertObject.doNotTestHashCodeMethod();
If developer do not want to test overridden toString method.
assertObject.doNotTestToStringMethod();
If developer do not want to test any overridden methods of Object class. toString, hashCode and equals
assertObject.doNotTestObjectClassOverriddenMethods();
If the developer want to test all the constructors of a class for unit testing.
assertObject.doTestAllConstructors();
NOTE:- Annotation, interface, enum and an abstract class will not be loaded.