@@ -470,6 +470,45 @@ public void analyzeTestCodeProperties() throws Exception {
470470 astVisitor .setScopeName (scopeName );
471471 /* recurse through AST */
472472 ast .visit (astVisitor );
473+
474+
475+
476+
477+ /*
478+ // Collect execution traces
479+ ArrayList traceList = null;
480+ HashMultimap<String, String> functionCallsMultiMap = HashMultimap.create();
481+ for (String jsFile: jsFileNames){
482+ System.out.println("Getting the traceList from " + jsFile);
483+ //System.out.println("return " + jsFile.replace(".js","") + "_getFuncionCallTrace();");
484+ //traceList = (ArrayList)((JavascriptExecutor) driver).executeScript("return " + jsFile.replace(".js","").replace("-", "_") + "_getFuncionCallTrace();");
485+ System.out.println("traceList: " + traceList);
486+ Map<String,String> traceMap;
487+ for (int i=0; i<traceList.size(); i++){
488+ traceMap = (Map<String,String>)(traceList.get(i));
489+ String testFunction = traceMap.get("testFunction");
490+ String calledFunctionName = traceMap.get("functionName");
491+ functionCallsMultiMap.put(testFunction, calledFunctionName);
492+ }
493+ }
494+
495+ int numUniqueFunCalls = 0;
496+ int maxUniqueFunCalls = 0;
497+ for (String testFunc : functionCallsMultiMap.keySet()) {
498+ Set<String> calledFunc = functionCallsMultiMap.get(testFunc);
499+ System.out.println(testFunc + ": " + calledFunc);
500+ if (calledFunc.size() > maxUniqueFunCalls)
501+ maxUniqueFunCalls = calledFunc.size();
502+ numUniqueFunCalls += calledFunc.size();
503+ }
504+
505+ System.out.println("numUniqueFunCalls: " + numUniqueFunCalls);
506+ if (functionCallsMultiMap.keySet().size()!=0)
507+ System.out.println("aveUniqueFunCalls: " + numUniqueFunCalls/functionCallsMultiMap.keySet().size());
508+ System.out.println("maxUniqueFunCalls: " + maxUniqueFunCalls);
509+ */
510+
511+
473512
474513 System .out .println ("FunctionCalls :" + astVisitor .getFunctionCalls ());
475514
@@ -481,57 +520,23 @@ public void analyzeTestCodeProperties() throws Exception {
481520 neverExecFunCallSites ++;
482521 }
483522 }
484-
485- coveredRegularFunc = astVisitor .getCoveredRegularFunc ();
486- missedRegularFunc = astVisitor .getMissedRegularFunc ();
487- coveredCallback = astVisitor .getCoveredCallback ();
488- missedCallback = astVisitor .getMissedCallback ();
489- coveredAsyncCallback = astVisitor .getCoveredAsyncCallback ();
490- missedAsyncCallback = astVisitor .getMissedAsyncCallback ();
491- coveredEventCallback = astVisitor .getCoveredAsyncCallback ();
492- missedEventCallback = astVisitor .getMissedEventCallback ();
493- coveredClosure = astVisitor .getCoveredClosure ();
494- missedClosure = astVisitor .getMissedClosure ();
495-
496- System .out .println ("++++ coveredRegularFunc: " + astVisitor .getCoveredRegularFunc ());
497- System .out .println ("++++ missedRegularFunc: " + astVisitor .getMissedRegularFunc ());
498- System .out .println ("++++ coveredCallback: " + astVisitor .getCoveredCallback ());
499- System .out .println ("++++ missedCallback: " + astVisitor .getMissedCallback ());
500- System .out .println ("++++ coveredAsyncCallback: " + astVisitor .getCoveredAsyncCallback ());
501- System .out .println ("++++ missedAsyncCallback: " + astVisitor .getMissedAsyncCallback ());
502- System .out .println ("++++ coveredEventCallback: " + astVisitor .getCoveredAsyncCallback ());
503- System .out .println ("++++ missedEventCallback: " + astVisitor .getMissedEventCallback ());
504- System .out .println ("++++ coveredClosure: " + astVisitor .getCoveredClosure ());
505- System .out .println ("++++ missedClosure: " + astVisitor .getMissedClosure ());
506-
507- System .out .println ("++++ neverExecFunCallSites: " + neverExecFunCallSites );
508-
509-
510- ArrayList <Integer > msimf = astVisitor .getMissedStatementInMissedFunction ();
511- //System.out.println("msimf: " + msimf);
512- for (int i =0 ; i <msimf .size (); i ++){
513- if (msimf .get (i ) >= 0 )
514- totalMissedStatementLinesInMissedFunctionCounter ++;
515- }
516523
517- totalMissedStatementLines = astVisitor . getMissedStatementLines (). size ();
518-
519- System . out . println ( "@ Total missed statement lines in missed functioncounter = " + totalMissedStatementLinesInMissedFunctionCounter );
520- System . out . println ( "@ Total number of missed statements = " + totalMissedStatementLines );
521- if ( totalMissedStatementLines != 0 ){
522- float ratio = ( float ) totalMissedStatementLinesInMissedFunctionCounter /( float ) totalMissedStatementLines ;
523- System . out . println ( "@ Percentage of missed statement in missed functions = " + ratio * 100 + "%" );
524- }
525-
526-
524+
525+ NumTests = astVisitor . getTestCounter ();
526+ NumAsyncTests = astVisitor . getAsynchTestCounter ( );
527+ NumAssertions = astVisitor . getAssertionCounter ( );
528+ //MaxFunCall = astVisitor.getMaxFunCall();
529+ //AveFunCall = astVisitor.getAveFunCall() ;
530+ //NumDOMFixture = astVisitor.getNumDOMFixture( );
531+ NumTriggerTest = astVisitor . getTriggerCounetr ();
532+ NumObjCreate = astVisitor . getNewExpressionCounter ();
533+
527534 System .out .println ("assertionCounter: " + astVisitor .getAssertionCounter ());
528535 System .out .println ("newExpressionCounter: " + astVisitor .getNewExpressionCounter ());
529536 System .out .println ("testCounter: " + astVisitor .getTestCounter ());
530537 System .out .println ("asynchTestCounter: " + astVisitor .getAsynchTestCounter ());
531- System .out .println ("asynchTestCounter: " + astVisitor .getTestCounter ());
532538 System .out .println ("trieggerCounter: " + astVisitor .getTriggerCounetr ());
533539
534-
535540 /* clean up */
536541 Context .exit ();
537542 } catch (RhinoException re ) {
@@ -541,6 +546,7 @@ public void analyzeTestCodeProperties() throws Exception {
541546 }
542547
543548 astVisitor .setVisitType ("" );
549+ astVisitor .resetTestCodeProperties ();
544550 }
545551
546552 public int getNumTests () {
0 commit comments