Skip to content
Permalink
Browse files

Go now have many more options: 'saveStats' to save stats of coverage …

…and any print outs, and 'showReadability' to print readability value of test suite by calculating all the language model scores of all the values in a test suite.
  • Loading branch information...
aalshrif90 committed Jul 2, 2019
1 parent 98da2db commit 5c19fb50791c5da34603c3dacfb569bf460f9cd7
@@ -52,6 +52,7 @@
private LangModel lm;
private long seed;
private String datagen = "";
private boolean readability;

public TestSuiteGenerator(Schema schema, TestRequirements testRequirements, ValueFactory valueFactory,
DataGenerator dataGenerator) {
@@ -65,13 +66,14 @@ public TestSuiteGenerator(Schema schema, TestRequirements testRequirements, Valu

// Another Constructor to initilize the LM and AVM
public TestSuiteGenerator(Schema schema, TestRequirements testRequirements, ValueFactory valueFactory,
DataGenerator dataGenerator, String datagen, long seed) {
DataGenerator dataGenerator, String datagen, long seed, boolean readability) {
this.schema = schema;
this.testRequirements = testRequirements;
this.valueFactory = valueFactory;
this.dataGenerator = dataGenerator;
this.datagen = datagen;
this.seed = seed;
this.readability = readability;
initialTableData = new HashMap<>();
}

@@ -83,19 +85,23 @@ public TestSuite generate() {
generateInitialTableData();
generateTestCases();
// Language Model
try {
lm = new LangModel("ukwac_char_lm");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (datagen.toLowerCase().contains("langmodel") || this.readability) {
try {
lm = new LangModel("ukwac_char_lm");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Check if we are using the LM or not
if (datagen.toLowerCase().contains("langmodel")) {
this.convertingLMValuesToTestSuite();
// this.langModelTestSuite();
}
// Calculate The test suite readability using a Language Model
this.calculateReadabilityOfTestSuite();
if (datagen.toLowerCase().contains("langmodel") || this.readability) {
this.calculateReadabilityOfTestSuite();
}
return testSuite;
}

@@ -21,6 +21,12 @@
protected String testSuite = "TestSchema";

// should default to Test + schema + .java
@Parameter(names = {"--seed"}, description = "Seed for generation")
protected Long seed = -0L;
@Parameter(names = {"--seed","-seed","--randomseed"}, description = "Random Seed")
protected long seed = -0L;

@Parameter(names = {"--showReadability","--readability","--read"}, description = "Calculates Readability of Character/String Values using a Language Model")
protected boolean readability = false;

@Parameter(names = {"--saveStats"}, description = "Save the stats info into a file results/generationOutput.dat Or results/readable.dat if any of these options selected --showReadability --readability --read")
protected boolean saveStats = false;
}
@@ -49,6 +49,10 @@ public static void main(String[] args) {
String datagenerator = jcp.generator;

String dbms = jcp.dbms;

boolean readabilityStats = jcp.readability;

boolean saveStats = jcp.saveStats;

String classname;

@@ -105,7 +109,8 @@ public static void main(String[] args) {
dbmsObject.getValueFactory(),
dataGeneratorObject,
datagenerator,
gc.seed);
gc.seed,
readabilityStats);
TestSuite testSuite = testSuiteGenerator.generate();

// if desired, write the INSERTs to a file for inspection
@@ -123,23 +128,38 @@ public static void main(String[] args) {
System.out.println("Coverage: " + report.coverage() + "%");
System.out.println("Num Evaluations (test cases only): " + report.getNumDataEvaluations(true));
System.out.println("Num Evaluations (all): " + report.getNumEvaluations(false));
System.out.println("Readable Score of TestSuite: " + testSuite.getReadableScore());
System.out.println("Averge Length of Strings: " + testSuite.getlengthOfStringsAverage());
System.out.println("Number of Empty: " + testSuite.getnumberOfEmptyStrings());
// CSV For readable test suites
CSVFileWriter writer = new CSVFileWriter("results" + File.separator + "readable.dat");
if (readabilityStats || datagenerator.toLowerCase().contains("langmodel")) {
System.out.println("Readable Score of TestSuite: " + testSuite.getReadableScore());
System.out.println("Averge Length of Strings: " + testSuite.getlengthOfStringsAverage());
System.out.println("Number of Empty: " + testSuite.getnumberOfEmptyStrings());
}
// Save stats into a DAT file
if (saveStats && !readabilityStats) {
CSVFileWriter writer = new CSVFileWriter("results" + File.separator + "generationOutput.dat");
CSVResult mResult = new CSVResult();
mResult.addValue("schema", schemaObject.toString());
mResult.addValue("dbms", dbms);
mResult.addValue("criterion", criterion);
mResult.addValue("datagenerator", datagenerator);
mResult.addValue("coverage", report.coverage());
writer.write(mResult);
System.out.println("All Results Printed in the following file: " + "results" + File.separator + "generationOutput.dat");
}

CSVResult mResult = new CSVResult();
mResult.addValue("schema", schemaObject.toString());
mResult.addValue("dbms", dbms);
mResult.addValue("criterion", criterion);
mResult.addValue("datagenerator", datagenerator);
mResult.addValue("readableScore", testSuite.getReadableScore());
mResult.addValue("AverageStringLength", testSuite.getlengthOfStringsAverage());
mResult.addValue("TotalEmptyStrings", testSuite.getnumberOfEmptyStrings());
mResult.addValue("coverage", report.coverage());
writer.write(mResult);
System.out.println("All Results Printed in the following file: " + "results" + File.separator + "readable.dat");
if (saveStats && readabilityStats) {
CSVFileWriter writer = new CSVFileWriter("results" + File.separator + "readable.dat");
CSVResult mResult = new CSVResult();
mResult.addValue("schema", schemaObject.toString());
mResult.addValue("dbms", dbms);
mResult.addValue("criterion", criterion);
mResult.addValue("datagenerator", datagenerator);
mResult.addValue("readableScore", testSuite.getReadableScore());
mResult.addValue("AverageStringLength", testSuite.getlengthOfStringsAverage());
mResult.addValue("TotalEmptyStrings", testSuite.getnumberOfEmptyStrings());
mResult.addValue("coverage", report.coverage());
writer.write(mResult);
System.out.println("All Results Printed in the following file: " + "results" + File.separator + "readable.dat");
}

// failed initial table data generation attempts
if (report.getInitialTableDataGenerationAttemptsFailed() > 0) {
@@ -29,5 +29,11 @@

@Parameter(names = {"--seed","-seed","--randomseed"}, description = "Random Seed")
protected long seed = -0L;

@Parameter(names = {"--showReadability","--readability","--read"}, description = "Calculates Readability of Character/String Values using a Language Model")
protected boolean readability = false;

@Parameter(names = {"--saveStats"}, description = "Save the stats info into a file results/generationOutput.dat Or results/readable.dat if any of these options selected --showReadability --readability --read")
protected boolean saveStats = false;

}

0 comments on commit 5c19fb5

Please sign in to comment.
You can’t perform that action at this time.