Class FeatureIndexer
Feature/Scenario titles directly in the source .feature files
according to a configured IndexingMode.
A line whose existing number already matches the format mode would itself produce -
a single integer for a Feature, or for a Scenario/Scenario Outline
either a single integer (IndexingMode.SCENARIO) or <featureNumber>.<n>
(IndexingMode.ALL, matched against that line's own feature's resolved number) - is left
completely untouched: its number is "pinned". Every other numbered line (wrong format, or a
leftover from a different mode, or IndexingMode.OFF itself never expecting a number at
all) is stripped and, if mode numbers lines of that kind, assigned a fresh number one
past the highest pinned number seen so far (or from 1, if none are pinned yet) - so a newly
added file that happens to sort alphabetically before already-numbered files never bumps their
numbers, and fresh numbers always read as a continuation of the existing sequence rather than
backfilling a gap earlier in it. Passing forceRewrite = true instead ignores existing
numbers entirely and renumbers everything from scratch, exactly as if every file were being
numbered for the first time.
Never called with IndexingMode.CI: the caller skips invoking this class entirely for
that mode, since CI means the feature files must be left completely untouched, not even
to strip prior numbering the way IndexingMode.OFF does.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidreindex(List<File> featureFiles, IndexingMode mode, boolean forceRewrite) Rewrites every file infeatureFilesin place permodeandforceRewrite- see the class documentation for exactly what changes and what's left alone.
-
Constructor Details
-
FeatureIndexer
public FeatureIndexer()Creates a newFeatureIndexer.
-
-
Method Details
-
reindex
Rewrites every file infeatureFilesin place permodeandforceRewrite- see the class documentation for exactly what changes and what's left alone. Files are numbered in the order they appear infeatureFiles- the caller is responsible for ordering that list the way numbers should be assigned. A file is only rewritten on disk when its content actually changes.- Parameters:
featureFiles- the feature files collected for this run, in the order to number them inmode- the indexing mode to applyforceRewrite- whentrue, ignores existing numbers and renumbers everything from scratch; whenfalse, leaves already-correctly-numbered lines alone
-