My JUnit test cases consisted of two acceptance test and four behavioral test. For my acceptance tests, I tested whether DaBeast can win half the time against the sample robots Corners and Crazy. One of my behavioral test check whether DaBeast actually goes into one of the corners of the battlefield mainly the bottom left corner. The other test checked whether DaBeast travelled near the left wall by checking if it went to the bottom left corner and top left corner. Another behavioral test was to see if DaBeast rams its opponents. Lastly, I made a test to make sure that DaBeast's firing power is within range of what I set it to be.
The easiest test to create were obviously the acceptance test. All we needed to do was assert if we won the battles half the time. The behavioral tests were the difficult ones to create for me. I think it's because I wasn't familiar with the syntax of the snapshot interfaces that were built in robocode.
I'm not really 100% sure about the quality of my test cases. Two of the tests had bugs that I can't quite figure out how to fix. My bullet power test for example takes all the bullets in the battlefield at the end of each turn. This means that it also uses the bullets of the enemy robot for testing purposes. My robot only fires either to the power of two or three. For some reason, even if I was going against SittingDuck, I would see a bullet fired with the power of 1 which doesn't make sense to me. Another test that's flawed is when I check to see if DaBeast travels next to the left wall. It only checks whether DaBeast goes to the bottom and top left corners. DaBeast moves from the bottom left corner and goes straight up to the top left corner near the left wall. If anybody can help me fix that test then I'd really appreciate it.
When I ran Emma, it revealed that all of the methods of my test cases were executed. From my experience, it seems like having your code broken down into smaller pieces and testing each of those is the easiest way to test my robot. Click here to download the distribution of my system and see if you guys can implement my test cases in a much better way :).
-David Joel Lazaro
0 comments:
Post a Comment