Page 1 of 1

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

Posted: 17 Apr 2011, 07:37
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?

Posted: 20 Apr 2011, 14:45
by BonyYousuf
can't anyone answer on this???

Posted: 21 Apr 2011, 04:14
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.

Posted: 21 Apr 2011, 08:34
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

Posted: 01 Jun 2011, 14:19
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);
    }

Posted: 06 Jun 2011, 12:50
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

Posted: 07 Jun 2011, 09:19
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