-
Notifications
You must be signed in to change notification settings - Fork 255
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
[Ignore] on base classes does not work on derived classes. #3681
Comments
Hi @Bruhst, Would it be possible to get a full reproducer? I have tried with the following code: TestProject1.csproj: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest" Version="3.4.3" />
</ItemGroup>
</Project> Test1.cs: namespace TestProject1
{
[Ignore]
[TestClass]
public abstract class Test1
{
[TestMethod]
public void TestMethod1()
{
}
}
[TestClass]
public class Test2 : Test1
{
[TestMethod]
public void Test1()
{
}
}
} and I do see the 2 tests executed in 3.4.3
|
Hi @Evangelink, using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Example.Tests
{
[TestClass]
[Ignore]
public class SourceClassTests
{
[TestMethod]
public void Constructor_Tests()
{
Assert.Fail(); // Skipped in all versions
}
[TestClass]
public class MethodWithinSourceClass : SourceClassTests
{
[TestMethod]
public void Should_DoSomething()
{
Assert.Fail(); // Fails from TestFramework 3.5.0
}
}
}
} I had previously thought that we might move away from this structure for other reasons but up until 3.5.0 the |
I can reproduce. I wasn't aware of this behavior so we will need to do the following:
Additionally, we could add a property/ctor deciding if the behavior should be inherited or not as it doesn't feel natural to me. |
In version 3.5.2 the [Ignore] attribute on base classes does no work on the derived classes.
Example:
#if !DEBUG
[Ignore]
#endif
public abstract class DebugTestBase
{
...
}
[TestClass]
#if !RELEASE
[Ignore]
#endif
public abstract class ReleaseTestBase
{
...
}
[TestClass]
public class MyDebugTest1 : DebugTestBase
{
...
}
[TestClass]
public class MyReleaseTest1 : ReleaseTestBase
{
...
}
The expected behavior is that in RELEASE builds only unit tests deriving from ReleaseTestBase would be executed and in DEBUG builds only unit tests deriving from DebugTestBase.
In version 3.4.3 the behavior was exactly like expected but now we switched to version 3.5.2 and all unit tests are executed regardless which build configuration is used and regardless which is the base class of the unit test.
The text was updated successfully, but these errors were encountered: