未验证 提交 cd734417 编写于 作者: P Phodal Huang

feat: add empyt test

上级 e9c7f90e
......@@ -115,14 +115,12 @@ Examples Result:
"File": "examples/api/BookController.java",
"BS": "dataClass"
}
...
],
"lazyElement": [
{
"File": "examples/api/model/BookRepresentaion.java",
"BS": "lazyElement"
}
...
]
}
```
......@@ -437,6 +435,31 @@ results:
+--------+------------------+--------------------------------+
```
### Test Bad Smells
```
coca tbs
```
results
```json
[
{
"FileName": "_fixtures/tbs/code/EmptyTest.java",
"Type": "EmptyTest",
"Description": "",
"Line": 0
},
{
"FileName": "_fixtures/tbs/code/IgnoreTest.java",
"Type": "IgnoreTest",
"Description": "",
"Line": 0
}
]
```
## Dev
Install Go
......
......@@ -31,18 +31,37 @@ func (a TbsApp) AnalysisPath(deps []models.JClassNode, identifiersMap map[string
// TODO refactoring identify & annotation
for _, method := range clz.Methods {
fullName := clz.Package + "." + clz.Class + "." + method.Name
checkIgnoreTest(clz, identMethodMap[fullName], &results)
checkIgnoreTest(clz.Path, identMethodMap[fullName], &results)
checkEmptyTest(clz.Path, identMethodMap[fullName], method, &results)
}
}
return results
}
func checkIgnoreTest(clz models.JClassNode, method models.JMethod, results *[]TestBadSmell) {
func checkEmptyTest(path string, iMethod models.JMethod, cMethod models.JMethod, results *[]TestBadSmell) {
for _, annotation := range iMethod.Annotations {
if annotation.QualifiedName == "Test" {
if len(cMethod.MethodCalls) <= 1 {
tbs := *&TestBadSmell{
FileName: path,
Type: "EmptyTest",
Description: "",
Line: 0,
}
*results = append(*results, tbs)
}
}
}
}
func checkIgnoreTest(clzPath string, method models.JMethod, results *[]TestBadSmell) {
for _, annotation := range method.Annotations {
if annotation.QualifiedName == "Ignore" {
tbs := *&TestBadSmell{
FileName: clz.Path,
FileName: clzPath,
Type: "IgnoreTest",
Description: "",
Line: 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册