■■■■ Java Unit Test Library -Artery- Sample ■■■■
-Introducing a sample of using the Java unit test (Unit test) library Artery that I am developing. This article is the table of contents.
・ Samples will be added one by one.
-Artery also includes an algorithm library. See here. Java Algorithm Library-Artery-Sample
・ The Artery library can be downloaded from the following. Vector ⇒ Programming ⇒ Java Language version202005 --2020/05/13 release
The Artery library can be used free of charge, including for commercial use.
-Easy use of unit test library
ArTest.java
/**Determine if two objects are equal. */
public static boolean equals(String identifier,String name0,Object value0,String name1,Object value1)
/**Determine if two objects are not equal. */
public static boolean notEquals(String identifier,String name0,Object value0,String name1,Object value1)
・ Judgment of equality of numerical values ・ Sequential determination of array ★List,Set ★Map
ArTest.java
/**Determine if two objects are the same. */
public static boolean same(String identifier,String name0,Object value0,String name1,Object value1)
/**Determine if two objects are not the same object. */
public static boolean notSame(String identifier,String name0,Object value0,String name1,Object value1)
★ [Same object judgment]
ArTest.java
/**Determine if the boolean value is true.*/
public static boolean isTrue(String identifier,String name,boolean value)
/**Determine if the boolean value is true. */
public static boolean isFalse(String identifier,String name,boolean value)
★ [Authenticity judgment]
ArTest.java
/**Determine if the object is valid. */
public static <T> boolean isValid(String identifier,String checkerName,ArValidator<T> checker,String objName,T object) /**Determine that the object is not valid. */
public static <T> boolean isNotValid(String identifier,String checkerName,ArValidator<T> checker,String objName,T object)
-Adjustment of objects by ArValidator
ArTest.java
/**Determine if the object is null. */
public static boolean isNull(String identifier,String name,Object value)
/**Determine if the object is null. */
public static boolean isNotNull(String identifier,String name,Object value)
ArTest.java
/**Determine that there is data.The target is the following objects.String,List,Set,Map,ArMapOnMap,ArBiMap,ArMatrix. */
public static boolean isNotEmpty(String identifier,String name,Object value)
/**Determine that there is no data.The target is the following objects.String,List,Set,Map,ArMapOnMap,ArBiMap,ArMatrix. */
public static boolean isEmpty(String identifier,String name,Object value)
★ [empty judgment]
ArTest.java
/**Declare the success of the test.Return value is always true. */
public static boolean success(String identifier,String message)
/**Declare test failure.Return value is always false. */
public static boolean fail(String identifier,String message)
★[success,fail]
-Determine whether the container (Set, List, array, etc.) contains the specified element. -Determine the inclusion relationship between containers
ArTest.java
/**Check if the element is in the Collection. */
public static <T> boolean contains(String identifier,String nameSet,Collection<T> set,String nameElement,T element)
/**Determine if the element is in the Collection. */
public static <T> boolean notContains(String identifier,String nameSet,Collection<T> set,String nameElement,T element)
/**Determine if the element is in the array. */
public static <T> boolean contains(String identifier,String nameArray,T[] array,String nameElement,T element)
/**Determine if the element is not included in the array. */
public static <T> boolean notContains(String identifier,String nameArray,T[] array,String nameElement,T element)
★ [Collection element inclusion judgment] ★ [Arrangement element inclusion judgment]
ArTest.java
/**Check if all the elements of collecitoni B are included in collectioin A. */
public static <T> boolean contains(String identifier,String nameA,Collection<T> collectionA,String nameB,Collection<T> collectionB)
/**Determine if any of the elements in collection B are not included in collection A. */
public static <T> boolean notContains(String identifier,String nameA,Collection<T> collectionA,String nameB,Collection<T> collectionB)
/**Determine if all the elements of array B are included in array A. */
public static <T> boolean contains(String identifier,String nameA,T[] arrayA,String nameB,T[] arrayB)
/**Determine if any of the elements of array B are not included in array A. */
public static <T> boolean notContains(String identifier,String nameA,T[] arrayA,String nameB,T[] arrayB)
/**Determine if mapA contains all pairs of mapB. */
public static <T0,T1> boolean contains(String identifier,String name0,Map<T0,T1> mapA,String name1,Map<T0,T1> mapB)
/**Determine if any of the elements of mapB are not included in mapA. */
public static <T0,T1> boolean notContains(String identifier,String name0,Map<T0,T1> mapA,String name1,Map<T0,T1> mapB)
★ [Inclusive judgment between sets] ★ [Containment judgment between arrays] ★ [Inclusive judgment between Maps]
・ Zero / non-zero judgment ・ Judgment of the size of two numerical values
ArTest.java
/**Determine if the value is zero.The target is the following types.BigDecimal, Byte, Double, Float, Integer, Long, Short */
public static boolean isZero(String identifier,String name,Number value)
/***Determine if the value is non-zero.The target is the following types.BigDecimal, Byte, Double, Float, Integer, Long, Short */
public static boolean isNotZero(String identifier,String name,Number value)
ArTest.java
/**Determine if the two numbers are equal.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean equals(String identifier,String name0,Number value0,String name1,Number value1)
/**Determine if the two numbers are not equal.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean notEquals(String identifier,String name0,Number value0,String name1,Number value1)
/** value0 <Determine if it is value1.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean lessThan(String identifier,String name0,Number value0,String name1,Number value1)
/** value0 <=Determine if it is value1.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean lessEqual(String identifier,String name0,Number value0,String name1,Number value1)
/** value0 >Determine if it is value1.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean greaterThan(String identifier,String name0,Number value0,String name1,Number value1)
/** value0 >=Determine if it is value1.Integer,Long,Float,Double,Supports Big Decimal.Both types may be different. */
public static boolean greaterEqual(String identifier,String name0,Number value0,String name1,Number value1)
-Pass the ArValidator for numerical judgment to the following method and use it.
ArTest.java
/**Determine if the object is valid. */
public static <T> boolean isValid(String identifier,String checkerName,ArValidator<T> checker,String objName,T object)
/**Determine that the object is not valid. */
public static <T> boolean isNotValid(String identifier,String checkerName,ArValidator<T> checker,String objName,T object)
-Has the following functions. ・ Current date judgment ・ Current date and time judgment ・ Current day of the week judgment ・ Judgment of designated day of the week ・ Same day judgment
-Determine whether ArDate, Date, Calendar, and long are the current date.
ArTest.java
/**Determine if it matches the current date. */
public static boolean currentDate(String identifier,String name,ArDate date)
/**Determine if it matches the current date. */
public static boolean currentDate(String identifier,String name,java.util.Date date)
/**Determine if it matches the current date. */
public static boolean currentDate(String identifier,String name,java.util.Calendar cal)
/**Determine if it matches the current date. */
public static boolean currentDate(String identifier,String name,long time)
-Determine whether Date, Calendar, and long are the current date and time. -Specify the tolerance in minutes.
ArTest.java
/**Determine if it matches the current date and time.diff is acceptable(Minutes) */
public static boolean currentTime(String identifier,String name,java.util.Date date,int diff)
/**Determine if it matches the current date and time.diff is acceptable(Minutes). */
public static boolean currentTime(String identifier,String name,java.util.Calendar cal,int diff)
/**Determine if it matches the current date and time.diff is acceptable(Minutes). */
public static boolean currentTime(String identifier,String name,long time,int diff)
-Determine whether ArDate, Date, Calendar, long, ArYoubi are the current days of the week.
ArTest.java
/**Determine if it matches the current day of the week. */
public static boolean currentYoubi(String identifier,String name,ArDate date)
/**Determine if it matches the current day of the week. */
public static boolean currentYoubi(String identifier,String name,java.util.Date date)
/**Determine if it matches the current day of the week. */
public static boolean currentYoubi(String identifier,String name,java.util.Calendar cal)
/**Determine if it matches the current day of the week. */
public static boolean currentYoubi(String identifier,String name,long time)
/**Determine if it matches the current day of the week. */
public static boolean currentYoubi(String identifier,String name,ArYoubi youbi)
・ Judgment of current day of the week (date may be different)-Q05_03
-Determine whether ArDate, Date, Calendar, long, ArYoubi are specified days of the week.
ArTest.java
/**Determine if it matches the specified day of the week. */
public static boolean youbiEquals(String indentifier,String name,ArDate date,String youbiString,ArYoubi youbi)
/**Determine if it matches the specified day of the week. */
public static boolean youbiEquals(String indentifier,String name,java.util.Date date,String youbiString,ArYoubi youbi)
/**Determine if it matches the specified day of the week. */
public static boolean youbiEquals(String indentifier,String name,java.util.Calendar cal,String youbiString,ArYoubi youbi)
/**Determine if it matches the specified day of the week. */
public static boolean youbiEquals(String indentifier,String name,long time,String youbiString,ArYoubi youbi)
/**Determine if it matches the specified day of the week. */
public static boolean youbiEquals(String indentifier,String name,ArYoubi youbi0,String youbiString,ArYoubi youbi1)
・ Judgment of designated day of the week (regardless of date)
-Determine whether ArDate, Date, Calendar, and long are on the same day. -Determine whether the day is the same even if the time is different. ・ All the above combinations are available. The following shows the case of Date and Calendar.
ArTest.java
/**Same day judgment Date vs Calendar. */
public static boolean sameDate(String identifier,String name0,Date date0,String name1,Calendar cal1)
/**Non-same day judgment Date vs Calendar. */
public static boolean notSameDate(String identifier,String name0,Date date0,String name1,Calendar cal1)
-Determine if ArDate, Date, Calendar, long are on the same day
-Determine if two objects are in the same class, -Determine whether the object is of the specified class.
ArTest.java
/**Determine if two objects are in the same class. */
public static boolean sameClass(String identifier,String name0,Object value0,String name1,Object value1)
/**Determine if two objects are in the same class. */
public static boolean notSameClass(String identifier,String name0,Object value0,String name1,Object value1)
/**Determine if an object is an object of a particular class. */
public static boolean isThisClass(String identifier,String name0,Object value,String name1,Class clazz)
/**Determine if an object is an object of a particular class. */
public static boolean isNotThisClass(String identifier,String name0,Object value,String name1,Class clazz)
★ [Class judgment]
-The output format should include tab delimiters. ・ It can be used as a test result report by reading it in Excel.
-Automatic unit test result report creation
★ [Execution time measurement]
★ [Getting stacks and races]
JUnit4 ・ Judgment of equality of numerical values ・ Sequential determination of array ★ [JUnit4-Judgment of numerical value] ★ [JUnit4-List equality judgment] ★ [JUnit4-List inclusion judgment] ★ [JUnit 4-Set equality judgment] ★ [JUnit 4-Set inclusion judgment] ★ [JUnit 4-Map equality judgment] ★ [JUnit4-Map inclusion judgment] ★ [Various judgments of JUnit4-String] ★ [JUnit4-Authenticity judgment] ★[JUnit4-Success/Fail]
TestNG
Recommended Posts