Junit tests

Well,

I have worked out how to run your Junit tests in Eclipse. Easy once I worked out how. Eclipse ‘knows’ all about them as you would expect and can run them for you.

I’ve not used Junit before and am trying to work out what sort of tests I should be thinking about?

What’s the best way to proceed?

Fix a bug and write a test to cover it?

Do we just test classes in isolation, or do we try and write a test that loads up the tutorial module and trys to test higher level functions?

B.

*********** REPLY SEPARATOR ***********

On 2/11/2009 at 11:05 PM Joel Uckelman wrote:


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

I’ll give my short answer now, as I’m about to turn in for the night, and
a longer answer tomorrow:

The main purpose of unit tests is to make sure that individual methods
(“units”) work the way they should. All the tests we have so far check
that calling a method has the expected effects.

Writing tests which fail due to bugs is also a good idea, as then we can
test in an automated way whether we’ve (a) fixed, and (b) reintroduced
particular bugs.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

Some more thoughts on tests: It’s going to be a rare bug which is not local
to some specific method, and anyway it’s hard to write meaninful high-level
tests.

Another benefit I see of writing method-level tests is that it encourages
us to write losely-coupled classes. Easy-to-test classes are going to have
fewer depencencies and will use interfaces more—which are things we should
aim for when possible.

If you look at the tests which are in the trunk now, you’l see that I’m
testing at a very low level—but, since these tests pass, I’m pretty
confident that the classes being tested work properly.

One of the things I plan to do as part of my big model-view refactoring
project is to write tests for the model classes…

I think that you could write tests for many of the methods in the Jabber
server and client classes. One way to test a class which depends on other
classes is to create “mock” classes which exhibit the behavior you need.
This is something I haven’t done myself yet, though.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)