I'll admit while it was easy to implement, it took me quite some time to do it, 14 minutes to be exact! Here are some screenshots of my code, the first being from within my workbench in Eclipse:
Despite both the ease of the program and the time it took for me to implement it, most of the time I spent was using the JUnit tool to verify my program's correctness. Of course I could have written another class, perhaps naming it something intuitive like FizzBuzzTest, that would ensure the behavior of my program to be correct under the set conditions, but I wanted to be adventurous and try to use JUnit to create a JUnit testcase to check my program's correctness. After never having the experience of using it and seeing a demonstration of it and how it can be used in a class of mine, I was determined to use it, even for such a small task as this one. I convinced myself this would be just a sample, an experience I could look back on and say, "Oh, that where I got my feet wet." Here is another screenshot of my code, this time of the test the I created using JUnit to check if my getResult() method of my FizzBuzz class worked correctly:
I was glad to see that my code worked as intended and that my JUnit test case verified this. In spite of that, the most difficult experience I had was following the model of using JUnit from the demonstration I mentioned earlier since what I could recall of the model was hazy on the details. Specifically, I was having difficulty remembering things like what return type I should make my getResult() method so that it would be easier to test using the assertEquals() method in my FizzBuzzTester class and also the parameter types of the assertEquals() method. But after some note taking, I was able to fill in the missing gaps from my recollection of the model and successfully implemented my FizzBuzzTest program with desired results. All in all, I had a fun time playing around in Java again and learning a few new tricks while doing so. I wonder what is next for Java and me in the future?
No comments:
Post a Comment