|
1 | | -package entity; |
| 1 | +package entity; |
2 | 2 |
|
3 | 3 | import java.nio.file.Path; |
4 | 4 | import java.util.List; |
@@ -36,75 +36,82 @@ public void setTotalLines(int totalLines) { |
36 | 36 | } |
37 | 37 |
|
38 | 38 | public long getTestMethodWithoutAnnotationCount() { |
39 | | - return methods.parallelStream().filter((p)->p.isHasAnnotation()==false && p.isHasTestInName()==true).count(); |
| 39 | + return methods.parallelStream().filter((p) -> p.isHasAnnotation() == false && p.isHasTestInName() == true).count(); |
40 | 40 | } |
41 | 41 |
|
42 | 42 | public String getFilePath() { |
43 | 43 | return path.toAbsolutePath().toString(); |
44 | 44 | } |
45 | 45 |
|
46 | 46 | public long getTestAnnotationCount() { |
47 | | - return methods.parallelStream().filter((p)->p.isHasAnnotation()).count(); |
| 47 | + return methods.parallelStream().filter((p) -> p.isHasAnnotation()).count(); |
48 | 48 | } |
49 | 49 |
|
50 | | - public boolean isHasTestInFileName(){ |
51 | | - return path.getFileName().toString().toLowerCase().contains("test"); |
| 50 | + public boolean isHasTestInFileName() { |
| 51 | + String fileName = getFileNameWithoutExtension().toLowerCase(); |
| 52 | + if (fileName.startsWith("test") || fileName.startsWith("tests") || fileName.endsWith("test") || fileName.endsWith("tests")) |
| 53 | + return true; |
| 54 | + else |
| 55 | + return false; |
52 | 56 | } |
53 | 57 |
|
54 | | - public String getFileName(){ |
| 58 | + public String getFileName() { |
55 | 59 | return path.getFileName().toString(); |
56 | 60 | } |
57 | 61 |
|
| 62 | + public String getFileNameWithoutExtension() { |
| 63 | + String fileName = path.getFileName().toString().substring(0,path.getFileName().toString().toLowerCase().lastIndexOf(".java")); |
| 64 | + return fileName; |
| 65 | + } |
| 66 | + |
58 | 67 | public long getTotalTestMethods() { |
59 | 68 | return (getTestMethodWithoutAnnotationCount() + getTestAnnotationCount()); |
60 | 69 | } |
61 | 70 |
|
62 | | - public boolean getHas_junitframeworkTest(){ |
| 71 | + public boolean getHas_junitframeworkTest() { |
63 | 72 | return imports.get("junit.framework.Test"); |
64 | 73 | } |
65 | 74 |
|
66 | | - public boolean getHas_junitframeworkTestCase(){ |
| 75 | + public boolean getHas_junitframeworkTestCase() { |
67 | 76 | return imports.get("junit.framework.TestCase"); |
68 | 77 | } |
69 | 78 |
|
70 | | - public boolean getHas_orgjunitTest(){ |
| 79 | + public boolean getHas_orgjunitTest() { |
71 | 80 | return imports.get("org.junit.Test"); |
72 | 81 | } |
73 | 82 |
|
74 | | - public boolean getHas_androidtestAndroidTestCase(){ |
| 83 | + public boolean getHas_androidtestAndroidTestCase() { |
75 | 84 | return imports.get("android.test.AndroidTestCase"); |
76 | 85 | } |
77 | 86 |
|
78 | | - public boolean getHas_androidtestInstrumentationTestCase() |
79 | | - { |
80 | | - return imports.get("android.test.InstrumentationTestCase"); |
| 87 | + public boolean getHas_androidtestInstrumentationTestCase() { |
| 88 | + return imports.get("android.test.InstrumentationTestCase"); |
81 | 89 | } |
82 | 90 |
|
83 | | - public boolean getHas_androidtestActivityInstrumentationTestCase2() |
84 | | - { |
85 | | - return imports.get("android.test.ActivityInstrumentationTestCase2"); |
| 91 | + public boolean getHas_androidtestActivityInstrumentationTestCase2() { |
| 92 | + return imports.get("android.test.ActivityInstrumentationTestCase2"); |
86 | 93 | } |
87 | 94 |
|
88 | | - public boolean getHas_orgjunitAssert(){ |
| 95 | + public boolean getHas_orgjunitAssert() { |
89 | 96 | return imports.get("org.junit.Assert"); |
90 | 97 | } |
91 | 98 |
|
92 | | - public String getRelativeFilePath(){ |
| 99 | + public String getRelativeFilePath() { |
93 | 100 | String filePath = path.toAbsolutePath().toString(); |
94 | 101 | String[] splitString = filePath.split("\\\\"); |
95 | 102 | StringBuilder stringBuilder = new StringBuilder(); |
96 | 103 | for (int i = 0; i < 5; i++) { |
97 | 104 | stringBuilder.append(splitString[i] + "\\"); |
98 | 105 | } |
99 | | - return filePath.substring(stringBuilder.toString().length()).replace("\\","/"); |
| 106 | + return filePath.substring(stringBuilder.toString().length()).replace("\\", "/"); |
100 | 107 | } |
101 | 108 |
|
102 | | - public String getAppName(){ |
| 109 | + public String getAppName() { |
103 | 110 | String filePath = path.toAbsolutePath().toString(); |
104 | 111 | return filePath.split("\\\\")[3]; |
105 | 112 | } |
106 | 113 |
|
107 | | - public String getTagName(){ |
| 114 | + public String getTagName() { |
108 | 115 | String filePath = path.toAbsolutePath().toString(); |
109 | 116 | return filePath.split("\\\\")[4]; |
110 | 117 | } |
|
0 commit comments