You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some practice exercises have scenarios "to allow for selectively including/excluding test cases based on a property of the test case". We currently have not defined how these are treated within the PHP track.
At the time of writing, these are the scenarios in use within exercises:
Based on these categories, test generators can simply skip over "never" scenarios and treat "always" scenarios like "no scenario".
For the "optional" ones I suggest using PHP constants in students files (define('BIG_INTEGER', 1);) and inside the test methods if (!defined('BIG_INTEGER') || constant('BIG_INTEGER' !== 1)) { $this->markTestSkipped(); }. Using the functions to create / read the constants avoids the problems that arise, when including the students file into a class method (as we do in the test class).
The constants provide a means to easily pre-define them in the students stub file:
[...]
// Change this constant value to 1 if you want to test your solution using Unicode strings:define('UNICODE', 0);
class ExerciseName
{
[...]
}
The text was updated successfully, but these errors were encountered:
mk-mxp
changed the title
Draft: Use PHP constants as opt-in to exercise scenarios
Make use of practice exercise scenarios
May 4, 2024
Problem
Some practice exercises have scenarios "to allow for selectively including/excluding test cases based on a property of the test case". We currently have not defined how these are treated within the PHP track.
At the time of writing, these are the scenarios in use within exercises:
Suggestion
Scenarios can be grouped into categories based on how we want to treat them:
We decide, which scenarios we want to treat as "optional", "always" or "never". I think, this a way to use the categories:
concurrent
,library-test
, any unknown scenariodate
,datetime
,floating-point
,local-scope
big-integer
,immutable
,input-validation
,random
,runtime-validation
,unicode
Based on these categories, test generators can simply skip over "never" scenarios and treat "always" scenarios like "no scenario".
For the "optional" ones I suggest using PHP constants in students files (
define('BIG_INTEGER', 1);
) and inside the test methodsif (!defined('BIG_INTEGER') || constant('BIG_INTEGER' !== 1)) { $this->markTestSkipped(); }
. Using the functions to create / read the constants avoids the problems that arise, when including the students file into a class method (as we do in the test class).The constants provide a means to easily pre-define them in the students stub file:
The text was updated successfully, but these errors were encountered: