pa2 Question

7 views
Skip to first unread message

Jordan Hourani

unread,
Feb 28, 2012, 11:19:28 AM2/28/12
to cs310_s12
In the second step, I have coded the TestMap class and tested each
type of map. However, I do not get any exceptions, and I am a bit
confused about where to throw them. Currently I am just using most of
the data from the demo() method, which does not cause any exceptions.
Should I be setting up my test method in a way that will cause an
exception to be thrown? And if so, would that be something like trying
to remove a value that has already been removed? Thanks!

Betty O'Neil

unread,
Feb 28, 2012, 11:51:18 AM2/28/12
to Jordan Hourani, cs310_s12
You can read the Javadocs for Map to see exceptions thrown.
For ex., several throw ClassCastException, easy to provoke.
But the request here is to have code that won't stop testing
just because one call caused an exception, so you really just
have to put try { } around each separate Map call in your test
program. Note that test code is expected to be "sloppier" than
normal code.

Jordan Hourani

unread,
Feb 28, 2012, 1:08:41 PM2/28/12
to cs310_s12
Ah i see, thank you!
Reply all
Reply to author
Forward
0 new messages