Skip to content
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

Logging when running tests in parallel #480

Open
Laxynium opened this issue Oct 30, 2023 · 1 comment
Open

Logging when running tests in parallel #480

Laxynium opened this issue Oct 30, 2023 · 1 comment

Comments

@Laxynium
Copy link

Hi,
following steps specified in section about test parallelism https://github.com/haf/expecto#about-test-parallelism
I've created a few tests with logging inside to check how logging behaves.

module ExpectoLogging

open Expecto
open Expecto.Logging
open Expecto.Logging.Message

let logger = Log.create "Logger"

[<Tests>]
let tests =
    testList
        "all tests"
        ([ 1..10 ]
         |> List.map (fun i ->
             testCase $"failing test {i}" (fun () ->
                 logger.info (eventX "Info from test before {testNumber}" >> setField "testNumber" i)
                 Expect.isFalse true "Expected false")))

[<EntryPoint>]
let main argv =
    Tests.runTestsInAssemblyWithCLIArgs [] argv

I was expecting that logs from assertions and my custom logs would be grouped together and the order would be preserved,
that is having 3 tests:
"a"-> which logs "x" and then fails on assertion,
"b" -> which logs "y" and then fails on assertion,
"c" -> which logs "z" and then fails on assertion
expected output would be something like
-----test "a"------
"x"
Expected false

-----test "c"------
"z"
Expected false

----- test "b"------
"y"
Expected false

However, my custom logs in output are disconnected from its wrapping testCase - they are not grouped.
image

I'm not sure if I have missed something in documentation and this should be done differently to make it working.
Do you have any hints how could I achieve this behaviour?

@farlee2121
Copy link
Collaborator

I'm seeing the same issue.

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

No branches or pull requests

2 participants