Skip to content

Logging when running tests in parallel #480

@Laxynium

Description

@Laxynium

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions