Skip to content

Fix execution order of scheduled tests - #80

Merged
Burgyn merged 3 commits into
Kros-sk:masterfrom
pavolbetak:master
Jan 16, 2026
Merged

Fix execution order of scheduled tests#80
Burgyn merged 3 commits into
Kros-sk:masterfrom
pavolbetak:master

Conversation

@pavolbetak

@pavolbetak pavolbetak commented Jan 14, 2026

Copy link
Copy Markdown
Collaborator

Issue: The property that was loaded within the directive contains an incorrect value. The value is outdated and comes from the last run of the program, not the current one.

Analyzis: Scheduled tests (from directives in .http files) were executed after registered tests instead of before them.

Solution: Scheduled tests now executed immedietly, before registered tests.

Summary by CodeRabbit

  • New Features

    • Added JSON-HAS-ID-PROPERTY directive to validate and extract ID values from JSON responses
    • Introduced new authentication provider types for application integration
  • Documentation

    • Added directive docs for new retrying/testing capabilities
  • Tests

    • Added assertion and variable-driven ID validation in car tests
    • Added test ensuring scheduled tests run before registered tests
  • Chores

    • Version bumped to 1.5.1

✏️ Tip: You can customize this high-level summary in your review settings.

@matejicko
matejicko self-requested a review January 14, 2026 14:54
@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a JSON-HAS-ID-PROPERTY test directive and demo usage, introduces MyAuthProvider types, changes ExecuteScheduledTestsStep to use ITester, adds a test ensuring scheduled tests run before registered tests, documents a retry directive, and bumps version to 1.5.1.

Changes

Cohort / File(s) Summary
Test directive & demo updates
demo/.teapie/init.csx, demo/Tests/002-Cars/001-Add-Car-req.http, demo/Tests/002-Cars/001-Add-Car-test.csx
Adds JSON-HAS-ID-PROPERTY directive that extracts body.Id into a variable; adds MyAuthProvider and MyAuthProviderOptions types; applies directive in demo car request and updates test to read IdFromDirective and assert against it.
Documentation
docs/docs/directives.md
Inserts a RETRY-UNTIL-TEST-PASS directive documentation block under Retrying Directives (syntax, example, parameters).
Build metadata
src/Directory.Build.props
Bumps Version from 1.5.0 to 1.5.1.
Test execution pipeline
src/TeaPie/Testing/ExecuteScheduledTestsStep.cs
Constructor dependency changed from IRegistrator to ITester; invocation updated to call _tester.ExecuteOrSkipTest(test, test.TestCase) instead of the previous Test(...) call.
Test coverage
tests/TeaPie.Tests/ApplicationPipelineShould.cs
Adds ExecuteScheduledTestsBeforeRegisteredTests test verifying scheduled tests run before registered tests; adds CreateTest helper and new using directives for test-related namespaces.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A directive hops, a tiny cheer,
It finds the Id and stores it near.
Tests march in order, one then two,
Auth springs up, version bumps anew,
I nibble carrots and celebrate you! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'Fix execution order of scheduled tests' directly and clearly describes the main change in the changeset, which involves reordering test execution so scheduled tests run before registered tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@demo/Tests/002-Cars/001-Add-Car-test.csx`:
- Around line 28-30: The test is treating the directive value as a float and
passing it as the third argument to Equal (which xUnit treats as precision)
instead of asserting it; change tp.GetVariable<float>("IdFromDirective") to an
integral type that matches your JSON ID (e.g.,
tp.GetVariable<long>("IdFromDirective") or int as appropriate), then perform two
explicit assertions: one that requestJson.Id equals responseJson.Id, and a
separate assertion that the directive value equals the same ID (e.g.,
Equal(requestJson.Id, idFromDirective)). Ensure you reference the variables
requestJson.Id, responseJson.Id, idFromDirective and the tp.GetVariable call
when making the change.

In `@docs/docs/directives.md`:
- Around line 97-105: The Purpose sentence for the RETRY-UNTIL-TEST-PASS
directive has a grammatical error; update the Purpose field text for the `##
RETRY-UNTIL-TEST-PASS` directive so it reads "Retries the request until the
defined test passes." (modify the Purpose line associated with the
`RETRY-UNTIL-TEST-PASS` directive).
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc14936 and a288bfb.

📒 Files selected for processing (7)
  • demo/.teapie/init.csx
  • demo/Tests/002-Cars/001-Add-Car-req.http
  • demo/Tests/002-Cars/001-Add-Car-test.csx
  • docs/docs/directives.md
  • src/Directory.Build.props
  • src/TeaPie/Testing/ExecuteScheduledTestsStep.cs
  • tests/TeaPie.Tests/ApplicationPipelineShould.cs
🔇 Additional comments (5)
src/Directory.Build.props (1)

20-20: LGTM!

Patch version bump is appropriate for this bug fix that corrects the execution order of scheduled tests.

demo/.teapie/init.csx (1)

128-147: LGTM!

The new JSON-HAS-ID-PROPERTY directive correctly follows the established pattern for custom test directives. The try-catch appropriately handles cases where the response body isn't valid JSON or lacks an Id property.

demo/Tests/002-Cars/001-Add-Car-req.http (1)

14-14: LGTM!

The directive usage correctly demonstrates the new JSON-HAS-ID-PROPERTY directive registered in init.csx, extracting the Id property from the response and storing it in the IdFromDirective variable.

src/TeaPie/Testing/ExecuteScheduledTestsStep.cs (1)

6-20: LGTM! This is the core fix for the execution order issue.

The refactor from IRegistrator to ITester and using ExecuteOrSkipTest ensures scheduled tests are executed immediately rather than being registered for later execution. The method signature matches the usage, accepting Test and TestCase? parameters, and is properly awaited.

tests/TeaPie.Tests/ApplicationPipelineShould.cs (1)

105-153: Good coverage for scheduled-vs-registered test ordering.

This test clearly captures the execution-order regression and validates the intended pipeline behavior.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread demo/Tests/002-Cars/001-Add-Car-test.csx Outdated
Comment thread docs/docs/directives.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@docs/docs/directives.md`:
- Line 104: Update the Parameters line for `test-name` to correct grammar and
avoid nested backticks: change "The name of test defined in post-response .csx
script." to "The name of the test defined in the post-response .csx script." and
rewrite the parenthetical example so it doesn't nest backticks (e.g., show the
example with only one level of code markup or escape the inner backticks for the
`tp.Test` usage such as: (for example: tp.Test("test-name", () => { ... })).
Ensure the parameter label `test-name` and the reference to tp.Test remain
present and clear.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a288bfb and 18bfe1c.

📒 Files selected for processing (2)
  • demo/Tests/002-Cars/001-Add-Car-test.csx
  • docs/docs/directives.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • demo/Tests/002-Cars/001-Add-Car-test.csx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread docs/docs/directives.md
| **Syntax** | `## RETRY-UNTIL-TEST-PASS: <test-name>` |
| **Example Usage** | `## RETRY-UNTIL-TEST-PASS: Identifier should be a positive integer` |
| **Purpose** | Retries the request until the defined test passes. |
| **Parameters** | `test-name` – The name of test defined in post-response .csx script. (tp.Test(`test-name`, () => )) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor grammatical improvements needed in the Parameters field.

The Parameters description has two issues:

  1. Missing articles: "The name of test defined in post-response .csx script" should include articles for better readability.
  2. The nested backticks in the parenthetical example may not render correctly in Markdown.
📝 Proposed fix
-| **Parameters** | `test-name` – The name of test defined in post-response .csx script. (tp.Test(`test-name`, () => )) |
+| **Parameters** | `test-name` – The name of a test defined in a post-response .csx script (e.g., `tp.Test("test-name", () => { })`). |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| **Parameters** | `test-name` – The name of test defined in post-response .csx script. (tp.Test(`test-name`, () => )) |
| **Parameters** | `test-name` – The name of a test defined in a post-response .csx script (e.g., `tp.Test("test-name", () => { })`). |
🤖 Prompt for AI Agents
In `@docs/docs/directives.md` at line 104, Update the Parameters line for
`test-name` to correct grammar and avoid nested backticks: change "The name of
test defined in post-response .csx script." to "The name of the test defined in
the post-response .csx script." and rewrite the parenthetical example so it
doesn't nest backticks (e.g., show the example with only one level of code
markup or escape the inner backticks for the `tp.Test` usage such as: (for
example: tp.Test("test-name", () => { ... })). Ensure the parameter label
`test-name` and the reference to tp.Test remain present and clear.

@Burgyn
Burgyn merged commit ca6ca5f into Kros-sk:master Jan 16, 2026
5 checks passed
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