I am running some Selenium tests and I want to take a screen shot and upload it to Azure DevOps. I am using MSTest V2 and it does not appear to set the property "TestContext" to the test context. It is always null. I have created a property
public TestContext TestContext { get; set; }
I have tried it in my Base class, and in my inherited classes. I have tried it with a backing variable, and with out and I have tried Initializing it in a class Initialization (even though this seems wrong). This line
Console.WriteLine($"the TestContext is null {(TestContext == null).ToString()}");
Always returns TestContext is null It then goes on to fail (obviously).
Not sure what was wrong, but fixing it involved uninstalling the nuget packages and then reinstalling them. I tried reverting to MSTest and it started working. Then I went back to MSTest V2 and it was still working.