Skip to content

Commit 40d6b3a

Browse files
committed
more on test info
1 parent d8abc39 commit 40d6b3a

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/main/java/instrumentor/JSASTInstrumentor.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/main/java/instrumentor/TestCaseInfo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
public class TestCaseInfo {
44
private int testNumber;
55
private String type; // {"async", "sync"}
6-
private int numFunCall; // number of unique function calls in the test case
7-
private int numAssertions;
8-
private int numObjCreation;
9-
private int numTriggers;
6+
private int numFunCall = 0; // number of unique function calls in the test case
7+
private int numAssertions = 0;
8+
private int numObjCreation = 0;
9+
private int numTriggers = 0;
1010

11-
public TestCaseInfo(int testNumber){
11+
public TestCaseInfo(int testNumber, String type){
1212
this.testNumber = testNumber;
13+
this.type = type;
1314
}
1415

1516
public int getTestNumber() {

0 commit comments

Comments
 (0)