Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Unit Testing?

Author
Message
MegaJim
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Feb 2015 20:37
As somebody from an enterprise java background, I am quite reliant now on unit testing and TDD (writing tests first) to define the behaviour of a function/procedure.

I can't find any mention of unit testing for AppGameKit and I'm curious whether anybody else has attempted something?

I think I could hack something together by creating a separate AppGameKit project where the main executable just starts up, runs some values into my functions and if they aren't returning the expected values, I'd call EXIT with a log statement etc...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Feb 2015 20:48
For Tier 2 (C++) you could use Visual Studio TDD tools, if you've got that level of MSDN account (or a lot of money!)

For Tier 1 (Basic), it's down to you to devise your own testing.

I use Tier 1 and tend to write in a modular fashion. For example, put all high score functionality in one include file. I'll also include a test function in each module so that if I make any changes, I can rerun the test. I'm not using TDD, but I am unit testing.

One of my modules is a debug module, which I can use to create logs. There is nothing formal about any of this, but it works for me.

Quidquid latine dictum sit, altum sonatur
MegaJim
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Feb 2015 20:59
Thanks BatVink, I think I will progress to Tier 2 eventually, I wrote a 3d game at uni in c# using the directX APIs in Visual Studio, and at that point point I'll investigate the TDD tools, thanks for the heads up.

I've already started breaking down my code into independent modules, however whilst you mention logging, could you give me an idea as to where log messages are printed on Windows when calling Log(someMessage) - I experimented with that a bit and didn't manage to find where the log messages are printed.

Thanks again!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Feb 2015 21:12
I'll be honest, I don't know where the log is either. I use my own routines where I open a file and call a debug function to write to the file. I have numerous functions for adding separators etc in the file to make reading it easier.

I have a constant cDEBUG so that I can switch off logging simply by setting it to zero.

Quidquid latine dictum sit, altum sonatur
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Feb 2015 21:14 Edited at: 12th Feb 2015 21:17
Here's my code. You'll have to add cDEBUG and a couple of global variables that start g. in my code to make it work.

always call DebugStart() first to set up the system.
DebugSave() and DebugWriteSave() make sure the lines are written to the file before your program crashes. Not a good idea to use this in a tight loop unless bug-searching because it is constantly closing and reopening the file.

DebugWriteConsole writes to the screen. Can be used for slow updates, no good for outputting every program cycle.



Quidquid latine dictum sit, altum sonatur
MegaJim
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Feb 2015 21:25
Awesome BatVink!

Thanks for the great example

James

Login to post a reply

Server time is: 2024-05-25 11:09:28
Your offset time is: 2024-05-25 11:09:28