1. Installation Review
Installation was straightforward. Since everyone used the same base package with xml files pre-given, the process of running Ant builds was the same as doing so for my own package. JUnit, Checkstyle, PMD, and FindBugs tests were present - all ran successfully. Also, Emma did not report 100% coverage - this will be discussed in further detail in section 3, Test Cases.
2. Code format and conventions review
No errors were found from the automated check tools.
Manual code violations:
| File | Lines | Violation | Comments |
| WebSpiderExample.java | N/A | ? | Class name should reflect what the class does. ('example' no longer should be in class name) |
| WebSpiderExample.java | 16, 186 | EJS-35 | Use descriptive Javadoc comments. |
| WebSpiderExample.java | 75, 118 | EJS-9 | Use meaningful variable names. (even when they appear as function parameters) |
| WebSpiderExample.java | 82, 83, 140, * | ICS-SE-Java-9 | Use iterators. |
3. Test Case Review
Black Box Testing
The following equivalence classes were considered and tested:
Regular URL - the program performs as expected. A JUnit test reflects this.
URL with no links - Also produces expected results (0 links). No JUnit test is present for this case.
URL that isn't a HTML file - threw a NotHTML exception.
404 link - HttpNotFoundException thrown.
non-HTTP link - At first glance it is OK since it checks for the http at the beginning of the URL. However, "httpa://" ends up executing with a MalformedURLException.
Invalid command line parameters - If the fourth parameter isn't "-logging", it shows the example use screen, as well as the results (which ends up being zero). Aside from that, it does pass the following parameter tests:
- ensuring first parameter is either -totallinks or -mostpopular
- ensuring second parameter is a http URL
- ensuring third parameter is a nonnegative number
White Box Testing
Code coverage is not 100%. The following is a list of the code that is not executed in the test cases:
- Case where MostPopularPage has all pages with 0 links (line 100). This can be checked by using 0 as the depth factor for a URL.
- Exception catching statements at 169-174. This is because traversePages has its own catch block, meaning they will get caught in the recursive call rather than the calling function. These lines could possibly be removed.
- Main function accepting an invalid URL (httpnot://foo.bar).
Break da buggah:
Any case mentioned above where an exception gets thrown is a case where the program crashed due to unexpected behavior. These cases again are:
- invalid URL that starts with "http"
- 404 link
- non-html link
- fourth parameter that is not '-logging'
Conclusions:
In conclusion, I learned a lot of the issues that were wrong with my code by reading through Michal's implementation. One of the things about doing testing is that it is difficult to hold a scalpel to your own work, but it is easy to look for faults in other people's work. By doing so, it helps you to think about things that you did on your own version.
Reading through Michal's code started to make me wonder if I implemented my own WebSpider implementation correctly - I interpreted the number parameter of the program as the "maximum number of pages to visit" rather than the "maximum depth from starting page" parameter. I am unsure which is correct, but I can start to understand the advantage of groups - having more perspectives helps to reduce possible errors like this.
The other difficulty comes in devising test cases. Personally I find it a little awkward to devise a set of test cases prior to the implementation of a system, and with pressure on finishing, it reduces the emphasis on testing, which shouldn't be neglected. There are many test cases I would've wanted to put into my code but didn't, mainly due to being exhausted from coding. It does seem like there may be an advantage to writing the test cases before the actual code in this case.
I did enjoy reading through another person's code, however, and it did rattle my brain over ideas on improvements on my own code.
No comments:
Post a Comment