Skip to content

Marking New and Changed Tests

aryehcitron@gmail.com edited this page Oct 26, 2026 · 6 revisions

If you already know which tests a pull request added and which it edited, from your own script, a test-impact tool or a diff of the test files, you can mark them in the Kronikol report. Give each one of two tags, pr-new or pr-edited here (any names work). The report then has a chip for each in its Tags row, @pr-new in the search keeps them, and kronikol query scenarios <reports> --tag pr-new lists them. Nothing runs twice and no new option is needed: each route below puts the tag in something Kronikol already reads, before the report is built or rebuilt.

Kronikol does not work out what changed here. What counts as new or edited, and which test each change belongs to, is your detector's answer; this page carries it into the report.

Why tags

  • Every tag gets a chip in the report's Tags row, with the number of tests that carry it, and the row's ANY/ALL switch combines it with the tags you already have (Tags and Attributes › Tags). On a run ingested from a tests file, a tag that every test of a feature carries is also the feature's: the report draws it once, on the feature, and its chip still picks each of those tests.
  • In the search, @pr-new or tag:pr-new matches the tag (case-insensitively) and @pr-new || @pr-edited either one (Search and Filter Syntax › Tag Filtering (@tag)).
  • kronikol query scenarios --tag matches any part of a name: --tag pr-new lists the new tests and --tag pr- both kinds (Querying Reports). --label, the flag's name before 5.0.0, does the same.
  • A tag does not change which test it is. History keys a test by its suite, feature, scenario name and outline row, so its history carries on.

Before 5.0.0 only a category got a button in the report, so these recipes added category:pr-new and wrote categories into the data file. A category: tag still works, since the prefix is read and dropped.

Which route

How your report is built For example Where the tag goes
kronikol ingest of a capture in the tests format Jest through the harness on Ingesting From Jest, or any runner whose capture writes tests.ndjson tags on each test's start record
kronikol ingest of Cucumber Messages Cucumber-JVM, cucumber-js, playwright-bdd tags on each pickle
A Kronikol adapter in the test process ReqNRoll, xUnit, NUnit, MSTest, TUnit, LightBDD, BDDfy tags on each scenario of the run's TestRunReport.json, rendered again with kronikol merge

Each example reads your detector's answer from changed.json, in this shape; convert your detector's output to it:

{
  "tests": [
    { "path": "src/orders/orders.test.ts", "line": 40, "end": 58, "change": "edited" },
    { "path": "src/orders/refunds.test.ts", "line": 12, "end": 30, "change": "added" }
  ]
}
  • path is the test's file, from the repository's root with forward slashes.
  • line and end are the first and last lines of the test. For a Gherkin scenario, line is the line of its Scenario: or Scenario Outline: keyword and end is left out.
  • change is added or edited. An entry with any other value is ignored.

The examples use jq, which GitHub's hosted runners have.

Ingested tests: tags on the start record

Ingest reads a test's tags from its start record. Add the tag there, then run kronikol ingest as you do now:

jq -cR --slurpfile changed changed.json '
  fromjson? // empty
  | if .event == "start" then
      (.sourceFile // "") as $file
      | (.sourceLine // -1) as $line
      | [ $changed[0].tests[]
          | select(.path == $file and .line <= $line and $line <= (.end // .line))
          | if .change == "added" then "pr-new"
            elif .change == "edited" then "pr-edited"
            else empty end ] as $marks
      | if ($marks | length) > 0 then .tags = ((.tags // []) + $marks | unique) else . end
    else . end' kronikol-capture/tests.ndjson > tests.tagged.ndjson
mv tests.tagged.ndjson kronikol-capture/tests.ndjson
kronikol ingest kronikol-capture --tests kronikol-capture/tests.ndjson -o Reports
  • A test matches when its sourceFile is the entry's path and its sourceLine falls between line and end. So every run of a test written once and run many times, such as Jest's .each or a loop, is marked, and so is every attempt of a retried test.
  • sourceFile has to be written the way path is. Ingest leaves the capture's paths as the capture wrote them, so an absolute path or a backslash matches nothing.
  • A capture with no sourceLine can match by name instead. The harness on Ingesting From Jest writes the file and the test's full name, its describe titles and its own title joined by ›. Give each entry a name, bind the record's name beside its file with (.testName // "") as $name, and select on .path == $file and .name == $name. Each run of an .each table has a name of its own, so match those by line.
  • A line that is not JSON, such as the torn last line a killed worker can leave, is dropped; ingest would skip it anyway.
  • If you write the capture yourself, your harness can add the tag when it writes the start record instead.

Cucumber Messages: tags on the pickle

Kronikol reads a scenario's tags from its pickle's tags, less its feature's (see tag conventions), so add the tag to each pickle. A pickle names its scenario by id, and the scenario's line is in the Gherkin document:

jq -c -n --slurpfile changed changed.json --slurpfile messages cucumber/messages.ndjson '
  def scenarios: .feature.children[]? | (.scenario // empty), (.rule.children[]? | .scenario // empty);
  def file: (if startswith("[") and index("]:") then .[index("]:") + 2:] else . end) | split("\\") | join("/");
  (reduce ($messages[] | .gherkinDocument // empty | scenarios) as $s ({}; .[$s.id] = $s.location.line)) as $lines
  | $messages[]
  | if .pickle then
      (.pickle.uri | file) as $uri
      | $lines[.pickle.astNodeIds[0]] as $line
      | [ $changed[0].tests[]
          | select(.path == $uri and .line == $line)
          | if .change == "added" then "@pr-new"
            elif .change == "edited" then "@pr-edited"
            else empty end ] as $marks
      | if ($marks | length) > 0 then .pickle.tags = ((.pickle.tags // []) + ($marks | map({ name: . }))) else . end
    else . end' > messages.tagged.ndjson

Then pass messages.tagged.ndjson to kronikol ingest --cucumber-messages.

  • line is the line of the scenario's keyword. Every row of a scenario outline is a pickle of its own, with the outline's line, so every row is marked.
  • A pickle's URI is relative to the folder the runner ran in, so write path that way. The script drops the [chromium]: that playwright-bdd puts before the URI when the Playwright project has a name, and turns the backslashes of a run on Windows into forward slashes. Cucumber-JVM writes a classpath: URI for a feature it found on the classpath and a file: URI for one it read from disk; for those, write path as the URI the run wrote.
  • --slurpfile reads the whole messages file into memory, attachments included. For a very large file, the same steps in a short script of your own do the job.

A .NET run: tag the report's data, then render it again

An adapter in the test process takes a test's tags from the test code (Tags and Attributes), so they cannot be added from outside the run. Tag the report's data instead, and build the report again from it:

  1. Set GenerateMergeableData = true in the project's ReportConfigurationOptions. The run's TestRunReport.json then holds everything a report is built from (Merging Parallel Reports).
  2. After the run, add the tags to TestRunReport.json and render it with kronikol merge:
jq --arg project tests/Orders.Tests --slurpfile changed changed.json '
  .features[].scenarios[] |= (
    (if .sourceFile then $project + "/" + .sourceFile else "" end) as $file
    | (.sourceLine // -1) as $line
    | [ $changed[0].tests[]
        | select(.path == $file and .line == $line)
        | if .change == "added" then "pr-new"
          elif .change == "edited" then "pr-edited"
          else empty end ] as $marks
    | if ($marks | length) > 0 then .tags = ((.tags // []) + $marks | unique) else . end)' \
  Reports/TestRunReport.json > tagged-run.json
kronikol merge tagged-run.json -o Tagged/TestRunReport.html -t "Orders component tests"
  • Reports/ is the folder the run wrote its report to, under the test project's build output unless you configured another. $project is the test project's folder from the repository's root: a ReqNRoll scenario's sourceFile is relative to it, and its sourceLine is the line of its Scenario: keyword.
  • In the data file a tag is its bare name, pr-new, with no @ and no category: prefix.
  • -t sets the title, which is otherwise Test Run Report. Write the output to a folder of its own: kronikol merge also writes a .json beside the HTML, and refuses to overwrite its input.
  • The rebuilt report is the full interactive report. It has a History section only when --history names the ledger; Merging Parallel Reports lists the options.

Tests of the other adapters (xUnit, NUnit, MSTest, TUnit, LightBDD, BDDfy) carry no source location in the report, so match them by name. Give each entry a feature and a scenario, as TestRunReport.json holds them (each feature's name and each of its scenarios' name), and select on those:

jq --slurpfile changed changed.json '
  .features[] |= (.name as $feature | .scenarios[] |= (
    .name as $scenario
    | [ $changed[0].tests[]
        | select(.feature == $feature and .scenario == $scenario)
        | if .change == "added" then "pr-new"
          elif .change == "edited" then "pr-edited"
          else empty end ] as $marks
    | if ($marks | length) > 0 then .tags = ((.tags // []) + $marks | unique) else . end))' \
  Reports/TestRunReport.json > tagged-run.json

What this does not show

The tags say which tests are new or edited, not what changed in them, and a removed test is not in the report to carry one. Showing the change itself in the report is #124.

Checked on a 5.0.0 build of Kronikol.Tool: a tests capture, a playwright-bdd run's Messages (a scenario outline among them) and a data file, tagged by source location and by name, each give kronikol query scenarios --tag pr- the tests marked and no others. There the edits were made by a script of the same logic as the jq programs; the programs themselves ran with jq 1.7.1 in their 4.x form, which wrote category:pr-new, with Kronikol.Tool 4.26.4.

Home · 🔍 Search this wiki Full-text search across every page. The “Pages” list above matches page and heading names, not page content.


Demo


Getting Started

Common Tasks

Integration Guides

Uninstrumentable / polyglot backends

Extensions

Configuration

Features

Reference

Clone this wiki locally