Package Torello.Java.Build
Class Testing
- java.lang.Object
-
- Torello.Java.Build.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 therunTests
for each and every Java-Class-File in the'test-files/'
directory which has properly implemented theTestingClass
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'stest-files/
directory for the JSON-PackageTorello.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'stest-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 theTestingClass
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 theTestingClass.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 theTestingClass
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/Java/Build/Testing.java
- Open New Browser-Tab: Torello/Java/Build/Testing.java
File Size: 2,358 Bytes Line Count: 60 '\n' Characters Found
Internal Class: Compile Tests:
- View Here: CompileTests.java
- Open New Browser-Tab: CompileTests.java
File Size: 8,956 Bytes Line Count: 233 '\n' Characters Found
Internal Class: Run Tests:
- View Here: RunTests.java
- Open New Browser-Tab: RunTests.java
File Size: 7,890 Bytes Line Count: 183 '\n' Characters Found
How the Java-HTML Library Uses this Class:
- View Here: BuildJAR/Test.java
- Open New Browser-Tab: BuildJAR/Test.java
File Size: 702 Bytes Line Count: 29 '\n' Characters Found
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)
-
-
-
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 apublic 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 classRunBuild
.argv
- This is the list of arguments to the CLI ProcessoradditionalCompilerArgs
- 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);
-
-