Skip to content

[Linting Rule] Software Has Tests

github-actions[bot] edited this page Jun 16, 2026 · 1 revision

This document was generated from 'src/documentation/wiki-linter.ts' on 2026-06-16, 07:18:00 UTC presenting an overview of flowR's linter (v2.10.9). Please do not edit this file/wiki page directly.

Software Has Tests [overview]

reproducibility usability

This rule is a best-effort rule.

Checks whether the software project has tests (test files in a test directory or test function calls in R code).
This linting rule is implemented in src/linter/rules/software-has-tests.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The software-has-tests rule accepts the following configuration options:

Examples

cat("hello")

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "software-has-tests",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (0 ms)
   ╰ Software Has Tests (software-has-tests):
       ╰ certain:
           ╰ No tests found in the project
       ╰ Metadata: testFilesFound: 0, testCallsFound: 0, searchTimeMs: 0, processTimeMs: 0
All queries together required ≈0 ms (1ms accuracy, total 1 ms)

Show Detailed Results as Json

The analysis required 0.6 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "linter": {
    "results": {
      "software-has-tests": {
        "results": [
          {
            "certainty": "certain",
            "loc": [
              -1,
              -1,
              -1,
              -1
            ],
            "message": "No tests found in the project"
          }
        ],
        ".meta": {
          "testFilesFound": 0,
          "testCallsFound": 0,
          "searchTimeMs": 0,
          "processTimeMs": 0
        }
      }
    },
    ".meta": {
      "timing": 0
    }
  },
  ".meta": {
    "timing": 0
  }
}

Additional Examples

These examples are synthesized from the test cases in: test/functionality/linter/lint-software-has-tests.test.ts

Test Case: no tests at all

Given the following input:

cat("hello")

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Certain, message: 'No tests found in the project', loc: [-1, -1, -1, -1] }]

See here for the test-case implementation.

Test Case: test_that call detected

Given the following input:

test_that("basic", { expect_true(TRUE) })

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: standalone expect_true not detected

Given the following input:

expect_true(1 == 1)

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Certain, message: 'No tests found in the project', loc: [-1, -1, -1, -1] }]

See here for the test-case implementation.

Test Case: test file in tests directory

Given the following input:

cat("hello")

And using the following configuration:

{ addFiles: [new FlowrInlineTextFile('/project/tests/test_main.R', '')] }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: test file in test directory (singular)

Given the following input:

cat("hello")

And using the following configuration:

{ addFiles: [new FlowrInlineTextFile('/project/test/helper.R', '')] }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: unrelated file not counted

Given the following input:

cat("hello")

And using the following configuration:

{ addFiles: [new FlowrInlineTextFile('/project/R/main.R', '')] }

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Certain, message: 'No tests found in the project', loc: [-1, -1, -1, -1] }]

See here for the test-case implementation.

Test Case: standalone expect_equal not detected

Given the following input:

expect_equal(1 + 1, 2)

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Certain, message: 'No tests found in the project', loc: [-1, -1, -1, -1] }]

See here for the test-case implementation.

Test Case: tinytest runner run_test_dir

Given the following input:

run_test_dir("inst/tinytest")

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: standalone checkEquals not detected

Given the following input:

checkEquals(1 + 1, 2)

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Certain, message: 'No tests found in the project', loc: [-1, -1, -1, -1] }]

See here for the test-case implementation.

Clone this wiki locally