@@ -370,6 +370,39 @@ static public void testClassMethod(
370370 }
371371
372372
373+ static public void testClassField (String pkg , String className , String fieldName , Runnable fn ) {
374+ Utilities .testClassField (FQCN (pkg , className ), fieldName , fn );
375+ }
376+
377+ static public void testClassField (String fullyQualifiedClassName , String fieldName , Runnable fn ) {
378+ var classObject = Utilities .findClass (fullyQualifiedClassName );
379+
380+ if (classObject .isEmpty ()) {
381+ throw new AssertionFailedError (
382+ "Class not found: %s" .formatted (fullyQualifiedClassName ),
383+ "Class located at src/main/java/%s.java" .formatted (fullyQualifiedClassName .replaceAll ("\\ ." , "/" )),
384+ "Class not found"
385+ );
386+ }
387+
388+ where (Utilities .CLASS , classObject .get ()).run (() -> {
389+ var fieldObject = Utilities .findField (CLASS .get (), fieldName );
390+
391+ if (fieldObject .isEmpty ()) {
392+ throw new AssertionFailedError (
393+ "Class-field not found: %s#%s" .formatted (
394+ fullyQualifiedClassName , fieldName
395+ ),
396+ "Field to exist within class" ,
397+ "Field within class does not exist"
398+ );
399+ }
400+
401+ where (Utilities .FIELD , fieldObject .get ()).run (fn );
402+ });
403+ }
404+
405+
373406 //__________________________________________________________________________________________________________________
374407 //### Scoped method
375408 /** Scoped CLASS */
0 commit comments