1
2
3
4
5
6
7
8
9
10
11
12 package com.eviware.soapui.model.support;
13
14 import com.eviware.soapui.model.mock.MockOperation;
15 import com.eviware.soapui.model.mock.MockService;
16 import com.eviware.soapui.model.project.Project;
17 import com.eviware.soapui.model.testsuite.Assertable;
18 import com.eviware.soapui.model.testsuite.TestCase;
19 import com.eviware.soapui.model.testsuite.TestStep;
20 import com.eviware.soapui.model.testsuite.TestSuite;
21
22 public class ProjectMetrics
23 {
24 private final Project project;
25
26 public ProjectMetrics( Project project )
27 {
28 this.project = project;
29 }
30
31 public int getTestCaseCount()
32 {
33 int result = 0;
34
35 for( TestSuite testSuite : project.getTestSuiteList() )
36 result += testSuite.getTestCaseCount();
37
38 return result;
39 }
40
41 public int getTestStepCount()
42 {
43 int result = 0;
44
45 for( TestSuite testSuite : project.getTestSuiteList() )
46 {
47 for( TestCase testCase : testSuite.getTestCaseList() )
48 {
49 result += testCase.getTestStepCount();
50 }
51 }
52
53 return result;
54 }
55
56 public int getAssertionCount()
57 {
58 int result = 0;
59
60 for( TestSuite testSuite : project.getTestSuiteList() )
61 {
62 for( TestCase testCase : testSuite.getTestCaseList() )
63 {
64 for( TestStep testStep : testCase.getTestStepList() )
65 {
66 if( testStep instanceof Assertable )
67 {
68 result += ( ( Assertable )testStep ).getAssertionCount();
69 }
70 }
71 }
72 }
73
74 return result;
75 }
76
77 public int getLoadTestCount()
78 {
79 int result = 0;
80
81 for( TestSuite testSuite : project.getTestSuiteList() )
82 {
83 for (TestCase testCase : testSuite.getTestCaseList())
84 {
85 result += testCase.getLoadTestCount();
86 }
87 }
88
89 return result;
90 }
91
92 public int getMockOperationCount()
93 {
94 int result = 0;
95
96 for( MockService mockService : project.getMockServiceList() )
97 result += mockService.getMockOperationCount();
98
99 return result;
100 }
101
102 public int getMockResponseCount()
103 {
104 int result = 0;
105
106 for( MockService mockService : project.getMockServiceList() )
107 {
108 for( MockOperation mockOperation : mockService.getMockOperationList() )
109 {
110 result += mockOperation.getMockResponseCount();
111 }
112 }
113
114 return result;
115 }
116 }