How to debug the examples command line runner in image
When we get errors running all tests in headless mode it can be helpful to reproduce the issue in an image with a gui.
First step is to try and reproduce the issue locally in headless mode by running only a subset of tests, in the example below the ones in the package GToolkit-World
.
We can them simulate the same run in an image with GUI:
commandLine := CommandLineArguments withArguments: #( '--junit-xml-output' '--verbose' 'GToolkit-World' '--no-quit' ).
GtExamplesCommandLineHandler activateWith: commandLine
Instead of of using CommandLineHandler>>#activateWith:
we can also bypass most logic done by the handler and directly execute example.
handler := GtExamplesCommandLineHandler new commandLine: commandLine. packages := handler sortedPackageNamesToRun. examplesReportResult := handler basicRunExamplesInPackages: packages
We also do not need to use GtExamplesCommandLineHandler
. Instead we could directly use the example reporter GtExamplesHudsonReport
(this will be called by the command line handler)
GtExamplesHudsonReport runPackage: 'GToolkit-World' asPackage
GtExamplesHudsonReport runClass: GtWorldByScripterExamples
Or we can run a single test.
GtExamplesHudsonReport new initializeWithTestCases: {(GtWorldByScripterExamples>>#doesNotUnderstandDebugSession) gtExample}; reportName: GtWorldByScripterExamples package name, '-', GtWorldByScripterExamples name; run