Java Unit Test Library-Artery-ArValidator Validates Objects

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

Q02_02.java


package jp.avaj.lib.test;

import jp.avaj.lib.algo.ArValidator;

/**
 *Java unit test library-Artery-Validating an object with ArValidator
 *
 *ArValidator can be used to validate an object.
 *ArValidator can define various things, so it can extend the function of the test library..
 */
public class Q02_02 {
  public static void main(String[] args) {
    //Declare the start of the test case ⇒ Not required if aggregation is not required
    ArTest.startTestCase("Q02_02");

    //Definition of ArValidator
    ArValidator<String> validator = new ArValidator<String>() {
      @Override
      public boolean check(String value) {
        return value.startsWith("a") && value.endsWith("z");
      }
      //It is convenient to define toString because it will be output to the log..
      @Override
      public String toString() {
        return "For tentative test";
      }
    };

    L.p("Validation");
    {
      String str = "abcz";
      ArTest.isValid("abcz","validater",validator,"str",str);

      str = "abc";
      ArTest.isValid("abc ⇒ NG","validater",validator,"str",str);
    }

    L.p("Non-validation");
    //Use isNotValid when you want to determine that it is not valid ⇒ is not invalid
    {
      String str = "abcz";
      ArTest.isNotValid("abcz ⇒ NG","validater",validator,"str",str);

      str = "abc";
      ArTest.isNotValid("abc","validater",validator,"str",str);
    }

    //End the test case ⇒ Not required if aggregation is not required
    ArTest.endTestCase();
  }
}

result.txt


**** Q02_02 start ****
Validation
OK abcz:validater=For tentative test:str=abcz
NG abc ⇒ NG:validater=For tentative test:str=abc
jp.avaj.lib.test.Q02_02.main(Q02_02.java:35)
Non-validation
NG abcz ⇒ NG:validater=For tentative test:str=abcz
jp.avaj.lib.test.Q02_02.main(Q02_02.java:42)
OK abc:validater=For tentative test:str=abc
**** Q02_02 summary ****
test count = 4
success    = 2

Recommended Posts

Java Unit Test Library-Artery-ArValidator Validates Objects
Java Unit Test Library-Artery-Sample
Java Unit Test Library-Artery-Current Date Judgment
Java Unit Test Library-Artery / JUnit4-Array Equivalence
Java Unit Test Library-Artery / JUnit4-Numerical equality judgment
Java Artery-Easy to use unit test library
Automatic creation of Java unit test result report
java classes, instances, objects
Unit test with Junit.
[Java] JUnit4 test case example
[IntelliJ IDEA] Perform Unit Test
Introduction to Micronaut 2 ~ Unit test ~
Fastest Primality Test C # Java C ++
Java test code method collection
2018 Java Proficiency Test for Newcomers-Basics-
Unit test architecture using ArchUnit
Implementation of unit test code
Java unit tests with Mockito