Skip to content

Tests: add helper Stress attribute for stress testing #18452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
naming
  • Loading branch information
majocha committed Apr 7, 2025
commit 41be29d4de3d00949f731cad3e62c51992ea027c
4 changes: 2 additions & 2 deletions DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ For example:
module TimeCritical =
```

For stress testing async code you can use a custom `FSharp.Test.RepeatAttribute`.
For stress testing async code you can use a custom `FSharp.Test.StressAttribute`.
For example, applied to a single xUnit test case:
```fsharp
[<Theory; Repeat(Count = 1000)>]
[<Theory; Stress(Count = 1000)>]
```
it will start it many times at the same time, and execute in parallel.

Expand Down
4 changes: 2 additions & 2 deletions tests/FSharp.Test.Utilities/XunitHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type RunTestCasesInSequenceAttribute() = inherit Attribute()

// Helper for stress testing.
// Runs a test case many times in parallel.
// Example usage: [<Theory; Repeat(Count = 1000)>]
type RepeatAttribute([<ParamArray>] data: obj array) =
// Example usage: [<Theory; Stress(Count = 1000)>]
type StressAttribute([<ParamArray>] data: obj array) =
inherit DataAttribute()
member val Count = 1 with get, set
override this.GetData _ = Seq.init this.Count (fun i -> [| yield! data; yield box i |])
Expand Down