Skip to content

Tests may behave differently in Release configuration #326

@timbussmann

Description

@timbussmann

I've noticed that some tests which fail in Debug configuration no longer fail in our CI pipeline as the tests in the pipeline are running in Release configuration. Code optimizations applied in release config can lead to validations not properly working anymore.

I have a demo repro available here: https://github.com/timbussmann/ArchUnitNetRepro:

The problem is that due to async state machine optimizations, this code:

public async Task DoSomethingAsync()
    {
        await service.SomeAsyncMethod();
    }

does not violate the following assertion anymore since the actual call has been extracted into the async state machine:

Classes().Should().NotCallAny(MethodMembers().That().AreDeclaredIn(typeof(ExampleService)))

I'm aware that this isn't necessarily ArchUnit.NET's fault, but it's a problem one can easily run into without noticing for a long time, making the tests less useful.

Metadata

Metadata

Labels

kind/supportCategorizes issue or PR as a support question.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions