diff --git a/src/main/resources/org/eolang/lints/tests/test-word.xsl b/src/main/resources/org/eolang/lints/tests/test-word.xsl new file mode 100644 index 000000000..80dd521d1 --- /dev/null +++ b/src/main/resources/org/eolang/lints/tests/test-word.xsl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + warning + + The name of the object + + must not contain the word 'test' + + + + + + diff --git a/src/main/resources/org/eolang/motives/tests/test-word.md b/src/main/resources/org/eolang/motives/tests/test-word.md new file mode 100644 index 000000000..b32615a0c --- /dev/null +++ b/src/main/resources/org/eolang/motives/tests/test-word.md @@ -0,0 +1,26 @@ +# Test word + +Names of objects in test files must not contain the word 'test'. If an object +is a unit test, or a helper inside a unit test, or lives in a file whose top +object name ends with `-tests`, its name should describe the behavior it +verifies instead of repeating the word 'test'. + +Incorrect: + +```eo +# Tests for foo. +[] > foo-tests + # Test. + [] +> can-test-add + 42 > @ +``` + +Correct: + +```eo +# Tests for foo. +[] > foo-tests + # Test. + [] +> can-add-two-and-two + 42 > @ +``` diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml new file mode 100644 index 000000000..7a590f285 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-clean-test-names.yaml @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +input: | + [] > foo-tests + + [] +> can-add + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml new file mode 100644 index 000000000..2c01ab4b3 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/allows-test-word-in-regular-object.yaml @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +input: | + [] > app + testing-helper > testing-helper + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml new file mode 100644 index 000000000..edaa31153 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-nested-object.yaml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='4'] +input: | + [] > foo-tests + + [] +> can-setup + tests-helper > tests-helper + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml new file mode 100644 index 000000000..47cdea37d --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-in-test-object.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='3'] +input: | + [] > foo-tests + + [] +> can-test-add + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml new file mode 100644 index 000000000..8676d8f90 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-word/catches-test-word-in-helper.yaml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-word.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='4'] +input: | + [] > foo-tests + + [] > can-run + tests-helper > tests-helper + 42 > @