Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/signals/test-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export function isTestPath(file: string): boolean {
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i.test(file) ||
// JVM / C# / Swift `SomethingTest(s)`/`SomethingSpec` class-suffix convention
// (JUnit, Kotlin/ScalaTest, Spock, xUnit/NUnit, XCTest). Case-sensitive on the
// PascalCase suffix so it can't false-positive on words that merely end in
// "test"/"spec" (Latest.java, Contest.cs, manifest.scala).
/(^|\/)\w*(Tests?|Spec)\.(java|kt|kts|scala|cs|swift|groovy)$/.test(file) ||
/(^|\/)__snapshots__\//i.test(file)
);
}
Expand Down
16 changes: 16 additions & 0 deletions test/unit/test-evidence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ describe("test evidence helpers", () => {
expect(isTestPath("src/app/testing.py")).toBe(false); // no `test_` boundary ⇒ not a test
});

it("detects JVM / C# / Swift class-suffix test conventions", () => {
// Paths NOT under a test/ directory, so only the class-suffix rule can match.
expect(isTestPath("app/src/main/java/WidgetTest.java")).toBe(true); // JUnit
expect(isTestPath("app/UserServiceTests.kt")).toBe(true); // Kotlin
expect(isTestPath("modules/pricing/PricingSpec.scala")).toBe(true); // ScalaTest
expect(isTestPath("Services/OrderTests.cs")).toBe(true); // xUnit/NUnit
expect(isTestPath("Sources/App/LoginTests.swift")).toBe(true); // XCTest
expect(isTestPath("gradle/CartSpec.groovy")).toBe(true); // Spock
// Case-sensitive suffix: words merely ending in test/spec are not tests.
expect(isTestPath("app/src/main/java/Latest.java")).toBe(false);
expect(isTestPath("Services/Contest.cs")).toBe(false);
expect(isTestPath("modules/manifest.scala")).toBe(false);
// A non-JVM extension with the same class name is unaffected by this rule.
expect(isTestPath("lib/WidgetTest.rb")).toBe(false);
});

it("does not treat framework or integration directory names alone as test evidence", () => {
expect(isTestPath("src/integration/auth.ts")).toBe(false);
expect(isTestPath("src/playwright/client.ts")).toBe(false);
Expand Down
Loading