|
From: doug s. <hig...@ho...> - 2013-06-01 20:55:50
|
Testing> -L --logfile <file> With a non-graphical scene, like a KeySensor or StringSensor test, there are a few approaches to generating a test fixture: 1. with statusbarHud there's a ! panel, showing some console printout on the opengl window, so a snapshot of that would show a bit. 2. logfile. Freewrl has a -L --logfile <filename> option, generally saving what comes out on the console. Two logfiles could be compared: A) generate .fwplay freewrl KeySensor/KeySensorTestAll.x3d -R -N test4 generates recording/test4.fwplay: window_wxh = 600, 400 scenefile = KeySensor/KeySensorTestAll.x3d 1 52026.812000 "" "" 2 52027.312000 "" "6,0,398,153,0;" 3 52027.828000 "" "6,0,390,157,0;" ... . B) generate fixture (before your source code refactoring begins) freewrl KeySensor/KeySensorTestAll.x3d -F -N test4 -L fixture/test4.txt generates fixture/test4.txt: . resize_GL showed window updated window - leaving createwindow opengl version=3.3.0 1 52026.812000 "" "" initBrowserType isFreewrl=true isFlux=false isCortona=false shortname=FreeWRL longname=FreeWRL VRML/X3D Browser 2 52027.312000 "" "6,0,398,153,0;" 3 52027.828000 "" "6,0,390,157,0;" 4 52028.328000 "" "6,0,379,204,0;" 5 52028.828000 "" "" ... C) generate a playback after you've refactored some code freewrl KeySEnsor/KeySEnsorTestAll.x3d -P -N test4 -L playback/test4.txt generates playback/test4.txt: . resize_GL showed window updated window - leaving createwindow opengl version=3.3.0 1 52026.812000 "" "" initBrowserType isFreewrl=true isFlux=false isCortona=false shortname=FreeWRL longname=FreeWRL VRML/X3D Browser 2 52027.312000 "" "6,0,398,153,0;" 3 52027.828000 "" "6,0,390,157,0;" 4 52028.328000 "" "6,0,379,204,0;" 5 52028.828000 "" "" ... D) Then the fixture/test4.txt would be compared to the playback/test4.txt with perl compare. If equal, pass. If different fail. This will pass only if no date, time, file path or malloc pointer information shows up during the log sessions. -Doug . more.. Remember the goal with refactoring is to change the structure of the code but not its functionality - so before and after outputs should be identical to pass. So there's 4 steps to testing: A) generate automated test. In our case thats the .fwplay manually generated. B) generate a test fixture before refactoring code, by playing the automated test C) after refactoring, generate a playback file D) compare B and C output files. They should be the same if your refactoring was good. If a test fails, roll back your refactoring changes, and try again. |