How to do unit testing on Client and Server for SmartFox 2x?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
BonyYousuf
Posts: 120
Joined: 20 Feb 2011, 12:54

How to do unit testing on Client and Server for SmartFox 2x?

Post by BonyYousuf »

Hi all,
i have been wondering about how i can do unit testing for smartfox server. I believe it would be really difficult cause it would need to deal with AS3 coding and Java server side coding as well. Does anyone know any unit testing framework or have done unit testing on Smart fox Server?? If yes then could you please give us some details?
Do we need 2 different unit testing framework for server and client side? or is there any unit testing framework which covers both?
BonyYousuf
Posts: 120
Joined: 20 Feb 2011, 12:54

Post by BonyYousuf »

can't anyone answer on this???
grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

Post by grhwood »

this is SI (system integration) test or end-to-end test not unit test. And yes, in this case you will need both client side and server side.

Hope that help.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

The test cases I made for the Java and C# API simply are small clients to the API and require a running server. But like all good unit tests they do not leave a state on the server.

But in general its tricky, as you are "unit testing" your client.

You *could* unit test your server extension too outside the server. Code up some mock classes for e.g. User and other objects. I know of one guy who did that.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
KlingOne
Posts: 28
Joined: 11 Sep 2010, 12:26
Location: Germany
Contact:

Post by KlingOne »

I am currently trying to unit test my server.
Is there a way to get at the Smartfox Api for a unit test.
I need it because one of my extensions uses a timer like this.

Code: Select all

public void init()
    {
        SmartFoxServer sfs = SmartFoxServer.getInstance();

        // Schedule the task to run every second, with no initial delay
        taskHandle = sfs.getTaskScheduler().scheduleAtFixedRate(new TaskRunner(sfs.getAPIManager().getSFSApi()), 0, 1, TimeUnit.SECONDS);
    }
Stigma
Posts: 15
Joined: 22 Feb 2010, 13:30
Location: Switzerland

Post by Stigma »

I did a junit test case for SFS1.6. I'm actually coding a new one for 2X and I can give it to you when I finish it if you want.
That's only for server class testing and it's a test case class with an embedded dummy java client. I make the connection and all necessary work in the constructor. The methods of the test case check the behaviour of classes or small processes.

Thomas
Stigma
Posts: 15
Joined: 22 Feb 2010, 13:30
Location: Switzerland

Post by Stigma »

Here is the class : http://www.tvuilleumier.ch/resources

You can extend the SFSTestCase class for your application tests and override the setUp and tearDown methods to prepare your application for a specific testing environnement. Then you can extend the newly created test case class for all your tests.
I put my application specific test case class (SFSColonyTestCase) and an example (GalaxyTest).

Regards,

Thomas
Post Reply