Java Artery-Easy to use unit test library

Table of Contents ⇒ Java Unit Test Library-Artery-Sample

package jp.avaj.lib.test;

/**
Easy to use unit test library

-Although there are other test methods, the following method usage examples are introduced as the most frequent ones..
・ IsTrue ⇒ Determine if the given argument is true.
・ IsFalse ⇒ Determine if the given argument is false.
・ Equals ⇒ Determine if the two given arguments are equal.

-Although the following method was also used in this usage example, it is not necessary to use it when using it for debugging.
・ StartUnitTest
・ StartTestCase
・ EndTestCase
・ ReportTotalSummary

 */
public class Q01_00 {

  public static void main(String[] args) {

    //Do not display message ⇒ Note, only summary is displayed
    //I will comment this time
    // ArTest.testOutLevel = ArTestOutLevel.NONE;

    //Stop when NG occurs.
    //I will comment this time.
	// ArTest.testIfError = ArTestIfError.ABORT;

    /*
・ Start unit test.
-Use when you want to output the log to a file, unnecessary if you just display it on the screen
-Specify the test name and log output directory.
-The test name becomes part of the log file name.
・ Create a directory in advance.
     */
    ArTest.startUnitTest("unittest","c:/tmp");

    //Start test case, OK/Not needed if you don't need NG statistics
    ArTest.startTestCase("Leap year judgment class test");

    boolean result;

    //2020 is a leap year ⇒ result is true
    result = LeapYear.isLeapYear(2020);
    /*
・ Check the result.
-The first argument describes the purpose and content of the test,Comment on the library.
・ The second argument describes the name of the variable you want to judge..Comment on the library.
・ The third argument describes the variable you want to judge..
     */
    ArTest.isTrue("2020","result",result);

    //2100 is a normal year ⇒ result is correct to false
    result = LeapYear.isLeapYear(2100);
    /*
・ Check the result.
-The first argument describes the purpose and content of the test,Comment on the library.
・ The second argument describes the name of the variable you want to judge.,Comment on the library.
・ The third argument describes the variable you want to judge..
・ In case of NG, the line number is displayed.
    */
    ArTest.isFalse("2100","result",result);
    //
    //End the test case ⇒ The total in the test case is displayed, unnecessary if startTestCase is not done
    ArTest.endTestCase();


    L.p("");
    //Start test case, OK/Not needed if you don't need NG statistics
    ArTest.startTestCase("Kim Basinger's role name ⇒ movie name conversion class test");

    //Vicky Vale ⇒ The correct answer is Batman
    String movie = Kim.getMovieTitle("Vicky Vale");
    /*
・ Check the result
-The first argument describes the purpose and content of the test,Comment on the library.
-The second argument is the variable name of the expected value.,Comment on the library.⇒Since the expected value is described directly here"expected"Designated as
・ The argument of the third name is the expected value
・ The argument of the fourth name is the variable name of the variable you want to judge..,Comment on the library.
・ The argument of the fifth name is the variable you want to judge
     */
    ArTest.equals("Vicky Vale","expected","Batman","movie",movie);

    //Carol McCoy ⇒ The correct answer is Getaway
    movie = Kim.getMovieTitle("Carol McCoy");
    /*
・ Check the result
-The first argument describes the purpose and content of the test,Comment on the library.
-The second argument is the variable name of the expected value,Comment on the library.⇒Since the expected value is described directly here"expected"Designated as
・ The argument of the third name is the expected value
・ The argument of the fourth name is the variable name of the variable you want to judge.,Comment on the library.
・ The argument of the fifth name is the variable you want to judge
・ In case of NG, the line number is displayed.
・ The role name in Blondie is Karen McCoy.
     */
    ArTest.equals("Carol McCoy","expected","Getaway","movie",movie);

    //End the test case ⇒ The total in the test case is displayed, unnecessary if you do not need the total data
    ArTest.endTestCase();

    L.p("");
    //Display of aggregates of all test cases, unnecessary if aggregated data is not needed
    ArTest.reportTotalSummary();

  }
  ////////////The following is the class to be tested
  /**Leap year judgment class(Maybe there is a bug). */
  static class LeapYear {
    public static boolean isLeapYear(int year) {
      return ((year % 4) == 0);
    }
  }
  /**Kim Basinger's role name ⇒ movie name conversion class(Maybe there is a bug). */
  static class Kim {
    public static String getMovieTitle(String name) {
      if ("Vicky Vale".equals(name)) { return "Batman"; }
      if ("Carol McCoy".equals(name)) { return "Blondie"; }
      //Others omitted
      return null;
    }
  }
}

The result is as follows.

result.txt


****Leap year judgment class test start****
OK 2020:result=true
NG 2100:result=true
jp.avaj.lib.test.Q01_00.main(Q01_00.java:63)
****Leap year judgment class test summary****
test count = 2
success    = 1

****Kim Basinger's role name ⇒ movie name conversion class test start****
OK Vicky Vale:expected=Batman:movie=Batman
NG Carol McCoy:expected=Getaway:movie=Blondie
jp.avaj.lib.test.Q01_00.main(Q01_00.java:97)
****Kim Basinger's role name ⇒ movie name conversion class test summary****
test count = 2
success    = 1

**** total ****
total test count = 4
total success    = 2

Recommended Posts

Java Artery-Easy to use unit test library
Java Unit Test Library-Artery-Sample
[Java] How to use Map
[Java] How to use Map
How to use java non-standard library on IntelliJ IDEA
How to use java class
Use Maven to add your favorite Java library to your environment.
Introduction to Micronaut 2 ~ Unit test ~
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to use string.format
How to use Truth (assertion library for Java / Android)
How to use Java Map
[java] Reasons to use static
How to use Java variables
[Java] How to use Optional ①
How to use Java HttpClient (Get)
Java Unit Test Library-Artery-ArValidator Validates Objects
How to use Java HttpClient (Post)
[Java] How to use join method
Java Unit Test Library-Artery-Current Date Judgment
[Processing × Java] How to use variables
[Java] How to use LinkedHashMap class
[JavaFX] [Java8] How to use GridPane
Welcome to the Java Library Swamp! !!
How to use class methods [Java]
[Java] How to use List [ArrayList]
How to use classes in Java?
Java Unit Test Library-Artery / JUnit4-Array Equivalence
[Processing × Java] How to use arrays
How to use Java lambda expressions
[Java] How to use Math class
How to use Java enum type
I tested how to use Ruby's test / unit and rock-paper-scissors code.
Multilingual Locale in Java How to use Locale
Java Unit Test Library-Artery / JUnit4-Numerical equality judgment
Whether to use Java Comparable or Comparator
Use TMDA to parse IBM Java javacore
How to use submit method (Java Silver)
[Java] How to use the HashMap class
[Easy-to-understand explanation! ] How to use Java instance
I want to write a unit test!
[Java] How to use the toString () method
[Java] Use cryptography in the standard library
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
How to use Java classes, definitions, import
[Easy-to-understand explanation! ] How to use Java polymorphism
[Java] [Maven3] Summary of how to use Maven3
[Processing × Java] How to use the class
How to use Java Scanner class (Note)
[Processing × Java] How to use the function
[Easy-to-understand explanation! ] How to use ArrayList [Java]
[Java] How to use the Calendar class
[Java] Learn how to use Optional correctly
[Easy-to-understand explanation! ] How to use Java overload
try-catch-finally exception handling How to use java
[Easy-to-understand explanation! ] How to use Java encapsulation
I was addicted to a simple test of Jedis (Java-> Redis library)
Primality test Java
Use jenv to enable multiple versions of Java