Thank you for the tip. I found a MockSession-class on the internet and I made a MockRunData-class that returns that object. That works for now. I also checked out cactus and I might use it in the future if there is a need for it. I trust that methods such as removeUserFromSession are well tested so there is no need for me to create additional tests. Thanks for the help /Ludwig
-----Original Message----- From: Manaster, Carl [mailto:[email protected]] Sent: den 5 januari 2009 17:40 To: Turbine Users List Subject: RE: Can I create a RunData object that works in my test cases? Hi, Ludwig, > Is there any way to go around this error (and perhaps some > similar errors I haven't come across yes) and create some > kind of RunData object that would work in my test cases? For testing, I've written three very simple classes that implement RunData, ParameterParser, and Context, with empty bodies for most of the methods, implementing only the bits my tests need with simple HashMaps. I've found it makes many tests much easier. In your example, since my RunData's implementation has just an empty body for removeUserFromSession(), no exception would be thrown. If you needed to test user removal, of course, you would have to add behavior for that (and presumably for adding the user), but since (generally) we're testing the behavior of the systems we build, and not of the supplied components, a trivial implementation usually serves. If I had a lot of such testing to do, I might create completely empty implementations of the three interfaces, then subclass and implement the specific bits needed by a given test or test suite. Peace, --Carl --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
