Commit ce6212af authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

tweaking G2 to also directlty target abstract CUT if it has at least one concrete static method.

parent ffb0697a
......@@ -278,7 +278,8 @@ public class G2 {
List<G2> g2s = new LinkedList<G2>() ;
try {
Class CUT = loader.loadClass(CUTname) ;
if (CUT.isInterface() || Modifier.isAbstract(CUT.getModifiers())) {
boolean abstractCUT = Modifier.isAbstract(CUT.getModifiers()) ;
if (CUT.isInterface() || abstractCUT) {
// if CUT is an interface or abstract, find an implementation:
Class imp = imap.getRndImp(CUT) ;
if (imp!=null) {
......@@ -286,7 +287,20 @@ public class G2 {
g2s.add(new G2(imp.getName(),config)) ;
}
else t3log.warning(CUT.getName() + " is abstract or interface; but failed to find an implementation to target!");
if (abstractCUT) {
Method[] publicmethods = CUT.getMethods() ;
for (Method m : publicmethods) {
int m_ = m.getModifiers() ;
if (!Modifier.isAbstract(m_) && Modifier.isStatic(m_)) {
t3log.info(CUT.getName() + " is abstract, but it has at least one concrete public and static method; so we target the class too.");
g2s.add(new G2(CUTname,config)) ;
break ;
}
}
}
}
else g2s.add(new G2(CUTname,config)) ;
// we additionally constructs instances of G2 for every static inner
......
......@@ -68,7 +68,7 @@ public class T3SuiteGenAPI extends SuiteAPI2 {
impMap = new ImplementationMap(config.dirsToClasses,classesTobeScanned) ;
scope = new TestingScope(impMap,config.CUT) ;
scope.testingFromTheSamePackagePespective = config.assumeClientInTheSamePackage ;
scope.includePrivateAndDefaultMembers = config.includeInheritedMembers ;
scope.includePrivateAndDefaultMembers = config.includePrivateAndDefaultMembers ;
config.reportWriteln("-----");
config.reportWriteln("** Scanned : " + impMap.knownClasses.size() + " classes, "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment