Skip to content

Commit

Permalink
#52 itemized test results are listed in output
Browse files Browse the repository at this point in the history
  • Loading branch information
sashafirsov committed Sep 24, 2017
1 parent 0bd7af7 commit 16faa13
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,19 @@ public void sqlighterOperations() {
* if anything didn't work in the demo.
*/
Bootstrap.getInstance().getMobilighter().setText(sqlighterHelloLabel, "SQLighter DemoBase did not pass");
Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "Exception: " + e.getMessage());
// Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "Exception: " + e.getMessage());
return;
}
if (!testSummaryCheck()) {
Bootstrap.getInstance().getMobilighter().setText(sqlighterHelloLabel, "SQLighter DemoBase did not pass");
Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "One or more tests failed");
// Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "One or more tests failed");
return ;
}
/**
* Return greet string to display on the screen
*/
Bootstrap.getInstance().getMobilighter().setText(sqlighterHelloLabel, greetingStr);
Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "All tests passed.");
// Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, "All tests passed.");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.vals.a2ios.sqlighter.intf.SQLighterRs;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -25,30 +26,44 @@ public abstract class DemoBase {
*/
private int passedTestCount = 0;
private List<String> testList = new LinkedList<>();
HashMap<String, String> test2status = new HashMap<String, String>();

protected Object sqlighterHelloLabel, sqlighterDetailsLabel;
protected Object amfibianHelloLabel, amfibianDetailsLabel;
protected MobilAction sqlighterStartAction, amfibianStartAction;

protected void resetTestCounters() {
testList.clear();
test2status.clear();
passedTestCount = 0;
}
String currentTest="";
protected String currentTest(){ return currentTest; }
protected void checkTest(String name, boolean isPassed) {
testList.add(name);
if( !test2status.containsKey(name) )
testList.add(name);
test2status.put( name, isPassed?"passed":"failed");
if(isPassed) {
passedTestCount++;
}
updateTestStatus();
}


protected void startTest(String name) {
testList.add(name);
currentTest = name;
if( !test2status.containsKey(name) )
testList.add(name);
test2status.put(name, "...");
updateTestStatus();
}

protected void finishTest(boolean isPassed) {
if(isPassed) {
passedTestCount++;
}
test2status.put( currentTest(), isPassed ? "passed" : "failed" );
updateTestStatus();
}

protected void makeTestsFail() {
Expand All @@ -59,6 +74,31 @@ protected boolean testSummaryCheck() {
return testList.size() == passedTestCount;
}

String statusChar( String k )
{ String v = ""+test2status.get(k);
switch(v)
{ case "passed": return "\u2611";
case "failed": return "\u2610";
case "null" : return "\u2026";
case "..." : return "\u2026";
}
return k;
}
protected void updateTestStatus(){
StringBuffer b = new StringBuffer(2000);

for( String k : testList ){
b.append( statusChar( k ) + " " + k +'\n');
// for( String d : test2status.keySet() )
// if( d.indexOf(k) == 0 )
// b.append( statusChar( d )+" " +d +'\n');


}

Bootstrap.getInstance().getMobilighter().setText(sqlighterDetailsLabel, b.toString() );

}

protected void printAppointments(AnOrm<Appointment> anOrm) throws Exception {
System.out.println("Appointment records");
Expand Down

0 comments on commit 16faa13

Please sign in to comment.