I would like create an object in one Test method and use the created object in rest of the other [TestMethod]'s rather than re-writing the code to create. I was trying to declare a global variable inside the class and assign it during the creation test method. But when the control goes to next [TestMthod] the value of global variable becomes null.
namespace ABC
{
class UnitTest
{
[TestMethod]
public void CreateObject()
{
var createdObject = \\ logic to create object;
}
[TestMethod]
public void Display()
{
//Here i want to use the created object instead of using object.
}
}
}
How do i achieve this?