I have two projects: UnitTests.csproj (xunit) and IntegrationTests.csproj (specflow)
I'm using
dotnet test MySolution.sln --filter FullyQualifiedName\!~IntegrationTests
to run unit tests.
However, my IntegrationTests.csproj project contains a method decorated with [AfterTestRun]
attribute, and it appears that my command runs that method, understandably, even though no tests were run from IntegrationTests.csproj
project.
I have tried putting [Category("Integration")]
on the [AfterTestRun]
-decorated method, but that doesn't seem to be helping.
Question: How can I filter test lifecycle methods with dotnet test and xunit?
My workaround is to add the following code to all integration test lifecycle methods:
if (Environment.GetEnvironmentVariable("TEST_SERVER_URL") is null) return;