# Story2testcode/other

## Overview

The `story2testcode/Other` module is a **subpackage containing fixture classes used by the `story2testcode` tooling pipeline itself**. Rather than implementing business logic, these classes serve as synthetic test targets — deliberately minimal, varied stubs that exercise different code paths in the story-to-test-code generation system. They cover legacy and modern JUnit variants, TestNG, unannotated classes, and non-standard source locations to ensure the tool handles edge cases correctly.

## Key Classes and Interfaces

### `LegacyTest`
**Location:** [`story2-test-code/src/main/java/com/example/LegacyTest.java`](story2-test-code/src/main/java/com/example/LegacyTest.java)

Extends `junit.framework.TestCase`, the JUnit 3 test base class. This class has no methods of its own — it is a barebones legacy test class.

**Purpose:** Exercises the tool's ability to recognize and handle JUnit 3-style tests. Since JUnit 3 uses method name conventions (`testXxx`) rather than annotations, it tests a different detection path than annotation-based tests.

**Key details:**
- No test methods defined — the class itself is empty
- The inheritance from `TestCase` is the sole signal that this is a test class
- Located in `src/main/java`, which is an unusual location for test code

### `RogueTestAnnotated`
**Location:** [`story2-test-code/src/main/java/com/example/RogueTestAnnotated.java`](story2-test-code/src/main/java/com/example/RogueTestAnnotated.java)

An empty class that uses the JUnit 4 `@Test` annotation on its method.

**Purpose:** Tests how the tool handles annotation-based test detection in the **main** source tree (not `src/test`). This is a "rogue" test — test code that lives alongside production code rather than in a dedicated test directory.

**Key details:**
- Method `test()` is annotated with `@Test` and is `void`
- The class itself has no state or constructor logic
- Resides in `src/main/java`, making it an edge case for test discovery tools

### `TestNGTest`
**Location:** [`story2-test-code/src/main/java/com/example/TestNGTest.java`](story2-test-code/src/main/java/com/example/TestNGTest.java)

An empty class that uses the TestNG `@Test` annotation on its method.

**Purpose:** Validates that the tool recognizes TestNG-style test annotations, which differ from JUnit annotations (`org.testng.annotations.Test` vs `org.junit.Test`). This ensures the tool doesn't conflate the two frameworks.

**Key details:**
- Method `run()` is annotated with TestNG's `@Test` and is `void`
- Located in `src/main/java`, consistent with the "rogue" pattern
- Tests a different annotation classpath than JUnit tests

### `OrderServiceTest`
**Location:** [`story2-test-code/src/test/java/com/example/OrderServiceTest.java`](story2-test-code/src/test/java/com/example/OrderServiceTest.java)

The most conventional test class in the module — a standard JUnit 4 test located in the expected `src/test/java` directory.

**Purpose:** Serves as the baseline or "happy path" fixture. This class exercises the normal test discovery path that the tool would use in a typical Maven/Gradle project.

**Key details:**
- Method `test()` is annotated with JUnit 4's `@Test` and is `void`
- Properly located in the `src/test/java` tree
- Despite the name suggesting it tests `OrderService`, it is a standalone stub with no actual test assertions

### `UnannotatedInTest`
**Location:** [`story2-test-code/src/test/java/com/example/UnannotatedInTest.java`](story2-test-code/src/test/java/com/example/UnannotatedInTest.java)

A class that lives in the test source tree but has **no test annotations** on any of its methods.

**Purpose:** Tests the tool's behavior when encountering a file in the test directory that is *not* actually a test class. This is important because naive test discovery that only looks at file location would misclassify this class.

**Key details:**
- Method `run()` is **not** annotated — it is just a regular method
- Has no imports (no test framework dependency)
- Tests the distinction between "file in test dir" and "file that is actually a test"

### `ImportOnlyTest`
**Location:** [`story2-test-code/src/utils/ImportOnlyTest.java`](story2-test-code/src/utils/ImportOnlyTest.java)

A class that imports the JUnit `@Test` annotation but never uses it.

**Purpose:** Exercises the tool's handling of orphaned or unused imports. This class imports `org.junit.Test` but declares no `@Test`-annotated methods, which could cause incorrect test discovery if the tool naively checks for import presence.

**Key details:**
- Has no methods at all — completely empty
- Imports `org.junit.Test` but the annotation is never used
- Located in a non-standard `src/utils` directory

### `OrderServiceTestStandalone`
**Location:** [`story2-test-code/standalone/OrderServiceTest.java`](story2-test-code/standalone/OrderServiceTest.java)

A JUnit 4 test class located in a `standalone/` source directory — outside both `src/main/java` and `src/test/java`.

**Purpose:** Tests how the tool handles test classes in non-standard, custom source directories. Build systems like Maven and Gradle have specific conventions for source trees; the tool must gracefully handle out-of-convention layouts.

**Key details:**
- Method `test()` is annotated with `@Test` and is `void`
- Resides in the root `standalone/` directory
- Despite the name suggesting it tests `OrderService`, it is a standalone stub

## Class Relationships

```mermaid
flowchart TD
    subgraph main["src/main/java/com/example — Main source"]
        LT["LegacyTest"]
        RT["RogueTestAnnotated"]
        TN["TestNGTest"]
    end

    subgraph test["src/test/java/com/example — Test source"]
        OST["OrderServiceTest"]
        UIT["UnannotatedInTest"]
    end

    subgraph utils["src/utils — Utility source"]
        IOT["ImportOnlyTest"]
    end

    subgraph standalone["standalone — Standalone source"]
        OSST["OrderServiceTestStandalone"]
    end

    LT -->|"JUnit 3 pattern"| LT_STYLE["legacy"]
    RT -->|"JUnit 4 in main"| RT_STYLE["annotated"]
    TN -->|"TestNG style"| TN_STYLE["annotated"]
    OST -->|"standard JUnit 4 test"| OST_STYLE["annotated"]
    UIT -->|"not a test"| UIT_STYLE["no annotation"]
    IOT -->|"unused import"| IOT_STYLE["no test methods"]
    OSST -->|"JUnit 4 standalone"| OSST_STYLE["annotated"]

    classDef testClass fill:#e1f5fe,stroke:#01579b,color:#000
    classDef nonTestClass fill:#fff3e0,stroke:#e65100,color:#000
    class LT,RT,TN,OST,OSST testClass
    class UIT,IOT nonTestClass
```

## How the Module Works

These classes are not meant to work together as a system — they are **intentionally independent** stubs. Each one exercises a distinct detection or classification path within the `story2testcode` tooling:

1. **Framework detection** — `RogueTestAnnotated` and `OrderServiceTest` use `org.junit.Test`, while `TestNGTest` uses `org.testng.annotations.Test`. The tool must correctly distinguish between the two annotation packages.
2. **Version detection** — `LegacyTest` uses JUnit 3's `TestCase` inheritance, while others use JUnit 4 annotations. The tool should handle both versions.
3. **Annotation vs. naming convention** — JUnit 3 tests rely on `testXxx` method naming; JUnit 4/5 tests rely on annotations. The tool must support both approaches.
4. **Location flexibility** — Tests are scattered across `src/main`, `src/test`, `src/utils`, and `standalone/` to ensure the tool does not hardcode expected source directories.
5. **False positive rejection** — `UnannotatedInTest` and `ImportOnlyTest` ensure the tool does not misclassify non-test classes (unannotated methods, unused imports) as test classes.

## Data Model

There are no data classes, DTOs, or entity types in this module. All seven classes are intentionally minimal:
- No fields or state
- No constructors beyond the implicit default
- No inter-class references

Each class is a self-contained stub.

## Dependencies and Integration

This module uses three external test framework dependencies:

| Dependency | Used By | Purpose |
|---|---|---|
| `junit.framework.TestCase` | [`LegacyTest`](story2-test-code/src/main/java/com/example/LegacyTest.java) | JUnit 3 inheritance |
| `org.junit.Test` | [`RogueTestAnnotated`](story2-test-code/src/main/java/com/example/RogueTestAnnotated.java), [`OrderServiceTest`](story2-test-code/src/test/java/com/example/OrderServiceTest.java), [`ImportOnlyTest`](story2-test-code/src/utils/ImportOnlyTest.java), [`OrderServiceTestStandalone`](story2-test-code/standalone/OrderServiceTest.java) | JUnit 4 annotation |
| `org.testng.annotations.Test` | [`TestNGTest`](story2-test-code/src/main/java/com/example/TestNGTest.java) | TestNG annotation |

There are no internal module dependencies — no class imports or references another class in the same package.

## Notes for Developers

- **Intentionally empty.** These classes have no logic to read. Their purpose is structural: they exist to validate that the `story2testcode` tool can correctly classify, detect, and report test classes under various conditions.
- **Do not refactor to add behavior.** Adding assertions, test methods, or state to these stubs would break the test fixtures that exercise the tool's detection logic. Keep them minimal.
- **Location matters.** Each class is deliberately placed in a different source directory to test the tool's source tree handling. Changing a class's file path should be done with awareness of which edge case it covers.
- **Annotation vs. inheritance distinction.** When working on test detection logic, be careful not to conflate JUnit 3 `TestCase` inheritance with JUnit 4/5 annotation-based detection — they follow different code paths.
- **The `ImportOnlyTest` edge case is subtle.** It imports `org.junit.Test` but never uses it. Tooling that checks for import presence without verifying actual usage will produce a false positive here.
