Skip to content

McpServerStartsSuccessfullyViaStdio unit test fails randomly #493

@vladascibulskis

Description

@vladascibulskis

Another test that fails randomly:

Assert.IsNotNull failed. 'value' expression: 'response'. Should receive a response from MCP server.
at Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(Object value, String message, String valueExpression)
at Verifiable.Tests.ToolTests.McpServerTests.McpServerStartsSuccessfullyViaStdio() (file:///Users/vladascibulskis/Verifiable/test/Verifiable.Tests/ToolTests/McpServerTests.cs#L299,0)
at Verifiable.Tests.ToolTests.McpServerTests.McpServerStartsSuccessfullyViaStdio() (file:///Users/vladascibulskis/Verifiable/test/Verifiable.Tests/ToolTests/McpServerTests.cs#L315,0)
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodInfo.ExecuteInternalAsync(Object[] arguments, CancellationTokenSource timeoutTokenSource)

I believe it happens when test hits this 5s timeout:
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken); cts.CancelAfter(TimeSpan.FromSeconds(5)); string? response = await VerifiableCliTestHelpers.ReadLineWithTimeoutAsync(process.StandardOutput, cts.Token);

It happens only when I run the whole test suite. This test take ±5s+ and usually succeeds, but fails if it takes 7s+
If I run only this test it executes in half a second and I couldn't make it fail.
It is quite strange why single test is executing so much faster compared to when it's part of the whole suite. Is it because tests are running in parallel and multiple tests are starting same executable process?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions