Skip to content

Conversation

@KyleKincer
Copy link
Owner

@KyleKincer KyleKincer commented Nov 3, 2025

Standardize JSON output to use the same outputPath parameter as JUnit XML output, removing the jsonOutputPath parameter for consistency.

This change makes the API more consistent across output formats:

  • JSON:
  • JUnit XML:

Both formats now use the same parameter name, improving developer experience and reducing confusion.

Summary by CodeRabbit

  • New Features

    • Test reports can now be exported to JSON files with a configurable output path parameter
  • Documentation

    • Updated README and guide with examples demonstrating JSON output capabilities to both console and file
  • Tests

    • Modified visual indicators in test output status display

Standardize JSON output to use the same outputPath parameter as JUnit XML output, removing the jsonOutputPath parameter for consistency.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

Documentation enhanced with JSON output examples for stdout and file writing. TestRunner.4dm adds JSON-to-file output capability with outputPath parameter parsing, introduces _writeJSONToFile function, and replaces status icons with question marks in test output.

Changes

Cohort / File(s) Summary
Documentation Examples
README.md, docs/guide.md
Added new examples demonstrating JSON output to stdout and JSON output written to file with outputPath parameter
Test Runner Output Enhancements
testing/Project/Sources/Classes/TestRunner.4dm
Replaced checkmark/✗ status icons with question marks; added user parameter parsing for outputPath and writeJSONToFile flag; introduced _writeJSONToFile function to write JSON reports to file instead of logging to stdout; updated JSON report generation flow to conditionally route output based on outputPath presence

Sequence Diagram

sequenceDiagram
    participant User
    participant TestRunner
    participant JSONGen as JSON Generator
    participant FileWriter as File Writer
    participant Logger

    User->>TestRunner: Run tests with params (outputPath)
    TestRunner->>TestRunner: Parse user params
    TestRunner->>JSONGen: Generate JSON report
    JSONGen-->>TestRunner: JSON content
    
    alt outputPath provided
        TestRunner->>FileWriter: _writeJSONToFile(json, path)
        FileWriter->>FileWriter: Create directories if needed
        FileWriter->>FileWriter: Write JSON to file
        FileWriter->>Logger: Log file location & summary
    else outputPath not provided
        TestRunner->>Logger: Log JSON to stdout
    end
    
    Logger-->>User: Output result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • TestRunner.4dm functional changes: Review parameter parsing logic, new _writeJSONToFile function implementation, and conditional output routing to ensure file I/O operations are robust and error-handling is adequate
  • Cross-validation: Verify documentation examples accurately reflect the new outputPath parameter behavior and align with code implementation

Possibly related PRs

Poem

🐰 From stdout to files, our reports now flow,
With question marks dancing where icons would show,
JSON takes flight on the path that we choose,
Documentation blooms—new examples diffuse! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately reflects the main functional change: standardizing the JSON output parameter name from jsonOutputPath to outputPath for API consistency.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/write-json-to-file

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
testing/Project/Sources/Classes/TestRunner.4dm (1)

290-312: Restore distinct pass/fail glyphs

Line 290 and Line 312 now emit "? " for both passing and failing tests, so the human-readable report no longer differentiates success from failure at a glance. Please keep unique markers (e.g., for pass and for fail) or another clear distinction.

Apply this diff:

-					LOG EVENT(Into system standard outputs; "  ? "+$testResult.name+" ("+String($testResult.duration)+"ms)\r\n"; Information message)
+					LOG EVENT(Into system standard outputs; "  ✓ "+$testResult.name+" ("+String($testResult.duration)+"ms)\r\n"; Information message)-					LOG EVENT(Into system standard outputs; "  ? "+$testResult.name+" ("+String($testResult.duration)+"ms)"+$errorDetails+"\r\n"; Error message)
+					LOG EVENT(Into system standard outputs; "  ✗ "+$testResult.name+" ("+String($testResult.duration)+"ms)"+$errorDetails+"\r\n"; Error message)
🧹 Nitpick comments (1)
testing/Project/Sources/Classes/TestRunner.4dm (1)

824-827: Replace the placeholder summary text

Line 826 writes "All tests passed! ??", which reads like a placeholder and weakens the success message. Please restore the prior celebratory text (e.g., the original emoji or a plain "All tests passed!" string).

Apply this diff:

-		LOG EVENT(Into system standard outputs; "All tests passed! ??\r\n"; Information message)
+		LOG EVENT(Into system standard outputs; "All tests passed! 🎉\r\n"; Information message)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73799c7 and aae6580.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • docs/guide.md (1 hunks)
  • testing/Project/Sources/Classes/TestRunner.4dm (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
testing/Project/Sources/Classes/**/*.4dm

📄 CodeRabbit inference engine (CLAUDE.md)

testing/Project/Sources/Classes/**/*.4dm: Name 4D test classes with the suffix "Test" for auto discovery (e.g., ExampleTest.4dm)
Name test methods with the prefix "test_" so the framework recognizes and runs them
Use comment-based tagging in tests with "// #tags: tag1, tag2" to enable filtering
Opt out of parallel execution for a suite by adding "// #parallel: false" at the test class level
Disable automatic transactions for a test by adding "// #transaction: false" and manage transactions manually if needed
When manual control is required, use Testing context helpers: startTransaction, inTransaction, validateTransaction, cancelTransaction, withTransaction, withTransactionValidate
Control trigger behavior per test with annotations: "// #triggers: enabled" or "// #triggers: disabled"
Place 4D test classes under testing/Project/Sources/Classes/ so the framework can discover and run them
Tag integration tests explicitly with "// #tags: integration" (and enable triggers when needed) to support filtering

Files:

  • testing/Project/Sources/Classes/TestRunner.4dm
🧠 Learnings (2)
📚 Learning: 2025-10-20T18:19:46.650Z
Learnt from: CR
Repo: KyleKincer/testing PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-20T18:19:46.650Z
Learning: Applies to testing/Project/Sources/Classes/**/*.4dm : Name test methods with the prefix "test_" so the framework recognizes and runs them

Applied to files:

  • README.md
📚 Learning: 2025-09-22T13:15:15.427Z
Learnt from: CR
Repo: KyleKincer/testing PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-22T13:15:15.427Z
Learning: Applies to testing/Project/Sources/Classes/*Test.4dm : Use comment-based tagging with lines like "// #tags: unit, integration, slow" to categorize tests

Applied to files:

  • testing/Project/Sources/Classes/TestRunner.4dm

$suiteResult.passed+=1
If (This:C1470.outputFormat="human")
LOG EVENT:C667(Into system standard outputs:K38:9; " "+$testResult.name+" ("+String:C10($testResult.duration)+"ms)\r\n"; Information message:K38:1)
LOG EVENT:C667(Into system standard outputs:K38:9; " ? "+$testResult.name+" ("+String:C10($testResult.duration)+"ms)\r\n"; Information message:K38:1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few places n this file have changes from a symbol to ?. Is this intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants