Class Testing


  • public class Testing
    extends java.lang.Object
    A lightweight, simple framework for running tests on your code.

    View the Testing CLI:
    The following screen-capture demonstrates what the CLI Menu looks like. Unlike that provided for the Build-Framework, this CLI is extremely simple. This 'Testing' class provides but two Menu-Options.



    The first Menu-Option allows a user to request that all '.java' files within a package's 'test-files/' sub-directory (including any sub-dirctories of that, as well) be compiled using the 'javac' command.

    The second Menu-Option allows a user to Run the runTests for each and every Java-Class-File in the 'test-files/' directory which has properly implemented the TestingClass interface.

    There are links, both right here, and in the links below this description area to the classes:



    Example Test-Class Directory:
    The following lists the contents of the Java-HTML Library's test-files/ directory for the JSON-Package Torello.Java.JSON. Do note that the file-names for the following Test-Classes do not adhere to Java's stringent Package-Name and Directory-Name conventions. For the purposes this Testing-Feature of the Build-Package, a specialized Class-Loader (see: ByteArrClassLoader was built in order to abscond and divest itself from these stringent requirements. Any class that is has been placed insode of a directory or sub-directory of a Package's test-files/ directory will not heed the "expected" Package-Name for class (the one based on it's directory name), but rather will read the actual package directly from the Source-Code File. Please see the list of JSON Test Class's here:

    Torello.Java.JSON Tests

    Not every one of the classes listed in the above directory actually implements the TestingClass interface. Quite a few of the Test-Classes for the JSON-Package are part of a hierarchy, whereby a Top-Level Dispatch class invokes all of the "Sub-Tests." What is required is that any test which should be run - automatically - when invoking this class from using the CLI must be called from within a class which does implement the TestingClass.runTests method.

    In this Testing-Framework, there are two phases that may be invoked from the Command-Line Interface (CLI). The first is to invoke the Java-Compiler on all of the tests, and the second is to run all classes which have implemented the TestingClass



    Stateless Class:
    This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's @Stateless Annotation.

    • 1 Constructor(s), 1 declared private, zero-argument constructor
    • 1 Method(s), 1 declared static
    • 0 Field(s)


    • Method Summary

       
      Invoke this Method in order to use this CLI-Based Test-Tool
      Modifier and Type Method
      static void run​(BuildPackage[] pkgList, String[] argv, ReadOnlyList<String> additionalCompilerArgs, String testingLogDirName, String JAVAC_BIN)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • run

          🗕  🗗  🗖
        public static void run​
                    (BuildPackage[] pkgList,
                     java.lang.String[] argv,
                     ReadOnlyList<java.lang.String> additionalCompilerArgs,
                     java.lang.String testingLogDirName,
                     java.lang.String JAVAC_BIN)
                throws java.io.IOException
        
        This should be invoked by a Java-Class which has collected the 'argv' parameter from a public static void main method, and passed to this class' method.

        This method will invoke one of two, internal, classes:

        Parameters:
        pkgList - This should be the same list of packages provided to class RunBuild.
        argv - This is the list of arguments to the CLI Processor
        additionalCompilerArgs - This list may be null, and if it is, it shall be silently ignored.
        testingLogDirName - This may be any directory name. Output from the testing code will be written to both '.txt' files, and '.html' files.
        JAVAC_BIN - This parameter may be null, and it is it shall be silently ignored. This parameter expects to receive the 'javac' binary file-name.

        If this parameter is null, then whatever 'javac' binary is located in the current path environment will be used.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
         Ret2<Boolean, ReadOnlyList<BuildPackage>> r2 =
             new TestingCLI(pkgList).process(argv);
        
         if (r2.a)   CompileTests.compile(r2.b, additionalCompilerArgs, JAVAC_BIN);
         else        RunTests.run(r2.b, testingLogDirName);