@@ -42,6 +42,11 @@ public class JSASTInstrumentor implements NodeVisitor{
4242 private int newExpressionCounter = 0 ;
4343 private int triggerCounetr = 0 ;
4444
45+ private ArrayList <TestCaseInfo > testCaseInfoList = new ArrayList <TestCaseInfo >();
46+ public ArrayList <TestCaseInfo > getTestCaseInfoList () {
47+ return testCaseInfoList ;
48+ }
49+
4550 private ArrayList <Integer > coveredStatementLines = new ArrayList <Integer >();
4651 private ArrayList <Integer > missedStatementLines = new ArrayList <Integer >();
4752 public ArrayList <Integer > getMissedStatementLines () {
@@ -568,11 +573,14 @@ private void analyzeTestCodeFunctionCallNode(AstNode node) {
568573 if (targetNode .toSource ().equals ("QUnit.test" ) || targetNode .toSource ().equals ("test" )){
569574 testCounter ++;
570575 // add a new TestCaseInfo object
571- TestCaseInfo t = new TestCaseInfo (testCounter );
576+ TestCaseInfo t = new TestCaseInfo (testCounter , "sync" );
577+ testCaseInfoList .add (t );
572578 }
573579 if (targetNode .toSource ().equals ("QUnit.asyncTest" ) || targetNode .toSource ().equals ("asyncTest" )){
574580 testCounter ++;
575581 asyncTestCounter ++;
582+ TestCaseInfo t = new TestCaseInfo (testCounter , "async" );
583+ testCaseInfoList .add (t );
576584 }
577585 }
578586
@@ -585,8 +593,12 @@ private void analyzeTestCodeFunctionCallNode(AstNode node) {
585593
586594 String [] otherSkipList = { "QUnit.module" , "module" , "QUnit.test" , "test" , "QUnit.asyncTest" , "asyncTest" , "jQuery" , "$" , "start" , "stop" }; // start/stop for asynchronous control
587595
588- if (ArrayUtils .contains ( assertionSkipList , targetNode .toSource () ))
596+ if (ArrayUtils .contains ( assertionSkipList , targetNode .toSource () )){
589597 assertionCounter ++;
598+ TestCaseInfo t = testCaseInfoList .get (testCaseInfoList .size ()-1 );
599+ t .setNumAssertions (t .getNumAssertions ()+1 );
600+ System .out .println ("Test case " + t .getTestNumber () + " has " + t .getNumAssertions () + " assertions!" );
601+ }
590602
591603 if (ArrayUtils .contains ( assertionSkipList , targetNode .toSource () ) || ArrayUtils .contains ( otherSkipList , targetNode .toSource () )) {
592604 System .out .println ("Not counting the called function: " + functionName );
0 commit comments