You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the following test class, only ClassCleanup runs and there is a NullReferenceException.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
private static object Obj;
[ClassInitialize]
public static void ClassInit( TestContext context )
{
Obj = new object();
}
[ClassCleanup]
public static void ClassCleanup()
{
Console.WriteLine( Obj.GetType() );
}
[TestMethod]
[Ignore] // The only test in this class is ignored
public void TestMethod1()
{
Assert.AreEqual( 1, 1 );
}
}
}
Expected behavior
One of two scenarios
The class is not even instantiated and nothing runs
ClassInitialize and ClassCleanup run
Instantiating the class but running neither ClassInitialize nor ClassCleanup could leave some undisposed class variables... Though I'm wondering as I'm writing this if that's a bad practice and should be handled by an IDisposable test class.
Actual behavior
Only the class cleanup is executed, resulting in a NullReferenceException in this example.
My real life scenario is that we have a class with several tests and the only tests that matches the TestCaseFilter in this build is [Ignore]d.
Environment
VS 2017 15.5.5
MsTest v2 1.3.0-beta2, 1.2 and 1.1.18
The text was updated successfully, but these errors were encountered:
@dee-see : We acknowledge this to be bug on our end and we will be fixing this in our upcoming releases.
We would be happy to help you, if you would like to contribute a fix for the same.
Steps to reproduce
Run the following test class, only
ClassCleanup
runs and there is aNullReferenceException
.Expected behavior
One of two scenarios
ClassInitialize
andClassCleanup
runInstantiating the class but running neither
ClassInitialize
norClassCleanup
could leave some undisposed class variables... Though I'm wondering as I'm writing this if that's a bad practice and should be handled by anIDisposable
test class.Actual behavior
Only the class cleanup is executed, resulting in a
NullReferenceException
in this example.My real life scenario is that we have a class with several tests and the only tests that matches the TestCaseFilter in this build is
[Ignore]
d.Environment
VS 2017 15.5.5
MsTest v2 1.3.0-beta2, 1.2 and 1.1.18
The text was updated successfully, but these errors were encountered: