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

adding an opting in Config to also include private members of the CUT as targets.

parent 203c1647
......@@ -33,6 +33,7 @@ public class Config {
public Class CUT ;
public boolean assumeClientInTheSamePackage = true ;
public boolean includeInheritedMembers = true ;
public boolean includePrivateAndDefaultMembers = false ;
public int maxLevelOfObjectsNesting = 4 ;
public int maxCollectionSize = 3 ;
public int maxNumberOfStepRetry = 30 ;
......
......@@ -84,6 +84,7 @@ public class CustomSuiteGenAPI extends SuiteAPI2 {
impMap = new ImplementationMap(config.dirsToClasses,classesTobeScanned) ;
scope = new TestingScope(impMap,config.CUT) ;
scope.testingFromTheSamePackagePespective = config.assumeClientInTheSamePackage ;
scope.includePrivateAndDefaultMembers = config.includePrivateAndDefaultMembers ;
config.print() ;
......
......@@ -106,6 +106,9 @@ public class G2 {
g2sg = new G2SuiteGen(CUTname,config.CUTrootDir, config.useCoverageGuidance,config.useStaticInfo,config.dirOfStaticInfo) ;
g2sg.regressionMode = config.regressionMode ;
g2sg.injectOracles = config.injectOracles ;
// configuring testing scope:
g2sg.scope.testingFromTheSamePackagePespective = config.assumeClientInTheSamePackage ;
g2sg.scope.includePrivateAndDefaultMembers = config.includePrivateAndDefaultMembers ;
// initialize the worklist
if (config.worklistType.equals("random")) {
......
......@@ -5,6 +5,10 @@ public class G2Config {
public String CUTrootDir ;
public String dirOfStaticInfo ;
// some variables to define scope (which members of the CUT are to be tested)
public boolean assumeClientInTheSamePackage = true ;
public boolean includePrivateAndDefaultMembers = false ;
public String worklistType = "standard" ;
public boolean regressionMode = false;
......
......@@ -143,7 +143,6 @@ public class G2SuiteGen {
// setting up implementation-map and testing scope:
imap = new ImplementationMap(new String[0]) ;
scope = new TestingScope(imap,CUT) ;
// scope.testingFromTheSamePackagePespective = true ; true is already the default
// Forcefully adding private constructors to the scope... hackish.
scope.configureForADTtesting() ;
......
......@@ -61,6 +61,7 @@ public class G2_forSBST2016 {
config.numberOfCPUcores = numberOfcores ;
config.useCoverageGuidance = turnOnCoverageGuidance ;
config.useStaticInfo = turnOnUseOfStaticInfo ;
config.includePrivateAndDefaultMembers = true ; // force private members to be tested as well...
G2.generateSuites(CUTname, config, timebudget) ;
System.exit(-1);
}
......
......@@ -68,6 +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 ;
config.reportWriteln("-----");
config.reportWriteln("** Scanned : " + impMap.knownClasses.size() + " classes, "
......
......@@ -54,6 +54,7 @@ public class TestingScope {
* else only public members are included.
*/
public boolean testingFromTheSamePackagePespective = true ;
public boolean includePrivateAndDefaultMembers = false ;
// HACK... force certain constructors to be included, e.g. private ones:
public List<Constructor> forceConstructors = new LinkedList<Constructor>() ;
......@@ -389,6 +390,7 @@ public class TestingScope {
}
private boolean isVisible(Class declaringClass, int modifier) {
if (includePrivateAndDefaultMembers) return true ;
if (testingFromTheSamePackagePespective) {
if (declaringClass.getPackage() == CUT.getPackage())
return (! Modifier.isPrivate(modifier)) ;
......@@ -481,7 +483,8 @@ public class TestingScope {
public String toString() {
String s = "Testing scope:" ;
String accessScope = "\nIncluding only public members" ;
if (testingFromTheSamePackagePespective) accessScope = "\nIncluding non-private members" ;
if (includePrivateAndDefaultMembers) accessScope = "\nAlso including default and protected members" ;
else if (testingFromTheSamePackagePespective) accessScope = "\nAlso including default and protected members" ;
s += "CUT = " + CUT.getName() ;
// s += "\nConcrete type = " + CUTconcreteType ;
s += accessScope ;
......
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