Record Class TestDirective
- Record Components:
token- Source location of the directiverequirement- Optional requirement id this test anchors (null = unanchored)group- Optional group name for sequential execution (null = parallel)lineNumber- The line number the directive applies to (the program declaration line)
- All Implemented Interfaces:
Directive
@Test- parallel, unanchored@Test: "database" - execution group, unanchored@Test: "REQ:fraud-screening" - anchored, parallel@Test: "REQ:fraud-screening": "database" - anchored and grouped
The two parts are told apart by their content, not their position
A requirement id has the shape <PREFIX>:<slug> and so contains a colon; an execution
group may not contain one. That makes the classification total and order-independent, and it is
what closes an otherwise silent failure: a mistyped prefix such as "RREQ:foo" would
otherwise be a perfectly legal group name, dropping the requirement anchor with no diagnostic
anywhere. Any colon-bearing part is therefore treated as an anchor attempt, and a
malformed one is a compile error rather than a quiet degradation to a group.
Zero of the 622 @Test usages in the corpus contain a colon, so this rule was
enforceable from the day it landed with no migration.
The two fields also travel across phases on separate squirrelled keys. The group rides
TEST_DIRECTIVE, which TestRunner reads as the sequential execution group; packing
a requirement id into it would silently reschedule every anchored test into a group named after
its requirement.
-
Constructor Summary
ConstructorsConstructorDescriptionTestDirective(IToken token, String requirement, String group, int lineNumber) Creates an instance of aTestDirectiverecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.intWhich line number does this directive apply to.Provide a token from the source, by default if not possible supply synthetic.group()Returns the value of thegrouprecord component.booleanhasGroup()Check if this test has a group for sequential execution.final inthashCode()Returns a hash code value for this object.booleanCheck if this test anchors a requirement.booleanisForPhase(CompilationPhase phase) Is it for the particular compiler phase.intReturns the value of thelineNumberrecord component.Returns the value of therequirementrecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.type()What s the type of the directive.
-
Constructor Details
-
TestDirective
Creates an instance of aTestDirectiverecord class.- Parameters:
token- the value for thetokenrecord componentrequirement- the value for therequirementrecord componentgroup- the value for thegrouprecord componentlineNumber- the value for thelineNumberrecord component
-
-
Method Details
-
type
Description copied from interface:DirectiveWhat s the type of the directive. -
isForPhase
Description copied from interface:DirectiveIs it for the particular compiler phase.- Specified by:
isForPhasein interfaceDirective
-
getAppliesToLineNumber
public int getAppliesToLineNumber()Description copied from interface:DirectiveWhich line number does this directive apply to.- Specified by:
getAppliesToLineNumberin interfaceDirective
-
getDirectiveToken
Description copied from interface:DirectiveProvide a token from the source, by default if not possible supply synthetic.- Specified by:
getDirectiveTokenin interfaceDirective
-
hasGroup
public boolean hasGroup()Check if this test has a group for sequential execution. -
hasRequirement
public boolean hasRequirement()Check if this test anchors a requirement.An unanchored test is entirely legitimate and carries no requirement by design - a unit test over a shared primitive is not "about" any one requirement.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
token
-
requirement
Returns the value of therequirementrecord component.- Returns:
- the value of the
requirementrecord component
-
group
-
lineNumber
public int lineNumber()Returns the value of thelineNumberrecord component.- Returns:
- the value of the
lineNumberrecord component
-