Mockito

Hello Guys,
I've only recently learned about XMage and greatly enjoyed the product.
I happen to be a Java developer and I want to help improve the game where I can.
I'v Started by implementing a missing card: Chronozoa, but I found that testing my implementation isn't very efficient: the dev guid suggests to start the server in debug mode and connects with a client and start playing a game, using the test.dck and init.txt, thus testing the card in action.
This is called a full end-to-end test and it's very important to do, but it's usually done after some unit tests are in place to test much simpler stuff that don't need the hole system to be up, thus saving time.
The code base doesn't really have unit tests for cards and that's because the objects needed to manipulate the card in a test are complicated and hard to create. For example, the Game class.
Here is where Mockito comes to the rescure, Mockito is an open source mocking framework that makes it very easy to write unit tests.
What's mocking you ask? it allows you to ignore the objects that your testable unit is dependant on and test only your unit. This is done by creating a mock of those objects and defining how they interact with your unit in the test, thus easily creating the scenarios you to cover in the test.
It's much easier to show than to explain, so I'll be happy to provide examples in cards I implement if you guys will add Mockito for a trial run.
Best regards,
Gal Lerman
I've only recently learned about XMage and greatly enjoyed the product.
I happen to be a Java developer and I want to help improve the game where I can.
I'v Started by implementing a missing card: Chronozoa, but I found that testing my implementation isn't very efficient: the dev guid suggests to start the server in debug mode and connects with a client and start playing a game, using the test.dck and init.txt, thus testing the card in action.
This is called a full end-to-end test and it's very important to do, but it's usually done after some unit tests are in place to test much simpler stuff that don't need the hole system to be up, thus saving time.
The code base doesn't really have unit tests for cards and that's because the objects needed to manipulate the card in a test are complicated and hard to create. For example, the Game class.
Here is where Mockito comes to the rescure, Mockito is an open source mocking framework that makes it very easy to write unit tests.
What's mocking you ask? it allows you to ignore the objects that your testable unit is dependant on and test only your unit. This is done by creating a mock of those objects and defining how they interact with your unit in the test, thus easily creating the scenarios you to cover in the test.
It's much easier to show than to explain, so I'll be happy to provide examples in cards I implement if you guys will add Mockito for a trial run.
Best regards,
Gal Lerman