How to set up a test environment

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
My project is getting bigger an sometimes bug are tricky to find, so I am thinking about how to test classes and functions in a more isolated way.
Until now I only had some constants to skip waiting times or some parts of the game and enabling sets of constants with preprocessor directives:
Cerberus X:
#Print "************"+AppType +GLFW_GCC_MSIZE_WINNT +"Bit_Build*********"

#if CONFIG="debug"
    #Test=True
#EndIf

#Premium=False
#SlowDesktop=True
    
'Global Settings
Const SCR_WIDTH:Float = 1920
Const SCR_HEIGHT:Float = 1080

Const MUSIC_ON:Bool = False



#If Test
    Const GAME_ENABLED:Bool = False
            
    #If Premium
        #Print "Test Premium Version"
        Const MAX_USER_CNT:Int = 20
    #Else
        #Print "Test Standard Version"
        Const MAX_USER_CNT:Int = 5
    #Endif
        
    Const SAVESTATE_INTERVALL:Float = 6000.0
        
    
#Else
    Const GAME_ENABLED:Bool = True
    
    #If Premium
    #Print "Final Premium Version"
    Const MAX_USER_CNT:Int = 20
    #Else
    #Print "Final Standard Version"
    Const MAX_USER_CNT:Int = 5
    #Endif
        
    Const SAVESTATE_INTERVALL:Float = 60.0
    
#Endif
But how would you test single classes or groups of them?
I am also interested in how you go about it or how it should be done properly.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
The only thing i do is using reflection on my whole project to find syntax errors in my code that is currently not called.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Do you have a small example , how you do that?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
@Phil7 here you go. In my fantomCX framework, I (un)comment the following lines when I add new features. Just so everything is added to the build and trans will detect errors in code, that is currently not called and would not be included in a build. Either for a single module like below, our the whole framework.

Cerberus X:
Import reflection
#REFLECTION_FILTER+="|fantomCX.cftView"
'#REFLECTION_FILTER+="|fantomCX*"
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Thanks a lot! Maybe I need this amount of testing stuff, because my coding is not very clean, I did a lot of restructuring while getting experience and I often have bugs in it, that are hard to find for me. :oops:
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
I guessed something like that. Every intervention is just a piece in the puzzle of a working code, right?

I am going to open another thread for some related questions about suitable code structure.
 
Top Bottom