|
Implementing a QBE Query
Listing 1. This QBE query lets you retrieve test executions to determine the percentage of test failures. // Open the database
ObjectContainer db = Db4o.openFile("testsuites.YAP");
// Instantiate the template object, filling in
// only the name field
testTemplate = new TestSuite("Network Throughput");
// Execute the query
ObjectSet result = db.get(testTemplate);
fails = 0.0f;
total = 0.0f;
// Step through results,
while(result.hasNext())
{
testsuite = (TestSuite)result.next();
if(testsuite.getOverallScore()=='F')
fails += 1.0f;
total += 1.0f;
}
if(total == 0.0f)
System.out.println("No tests of that type found.");
else
{
System.out.println("Percent failed: " + (fails/total * 100.0f) + "%");
System.out.println("Total executed: " + total);
}
db.close();
|